mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-13 17:22:59 -04:00
Remove periods from receive mode time folder names, and save the message outside of the time folder
This commit is contained in:
parent
47e02d781a
commit
95e6985f86
1 changed files with 8 additions and 7 deletions
|
@ -377,7 +377,7 @@ class ReceiveModeRequest(Request):
|
||||||
# Figure out what files should be saved
|
# Figure out what files should be saved
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
date_dir = now.strftime("%Y-%m-%d")
|
date_dir = now.strftime("%Y-%m-%d")
|
||||||
time_dir = now.strftime("%H.%M.%S")
|
time_dir = now.strftime("%H%M%S")
|
||||||
self.receive_mode_dir = os.path.join(
|
self.receive_mode_dir = os.path.join(
|
||||||
self.web.settings.get("receive", "data_dir"), date_dir, time_dir
|
self.web.settings.get("receive", "data_dir"), date_dir, time_dir
|
||||||
)
|
)
|
||||||
|
@ -425,6 +425,9 @@ class ReceiveModeRequest(Request):
|
||||||
)
|
)
|
||||||
self.upload_error = True
|
self.upload_error = True
|
||||||
|
|
||||||
|
# Figure out the message filename, in case there is a message
|
||||||
|
self.message_filename = f"{self.receive_mode_dir}-message.txt"
|
||||||
|
|
||||||
# If there's an error so far, finish early
|
# If there's an error so far, finish early
|
||||||
if self.upload_error:
|
if self.upload_error:
|
||||||
return
|
return
|
||||||
|
@ -461,18 +464,15 @@ class ReceiveModeRequest(Request):
|
||||||
if text_message:
|
if text_message:
|
||||||
if text_message.strip() != "":
|
if text_message.strip() != "":
|
||||||
self.includes_text = True
|
self.includes_text = True
|
||||||
filename = "message.txt"
|
with open(self.message_filename, "w") as f:
|
||||||
local_path = os.path.join(self.receive_mode_dir, filename)
|
|
||||||
|
|
||||||
with open(local_path, "w") as f:
|
|
||||||
f.write(text_message)
|
f.write(text_message)
|
||||||
|
|
||||||
self.web.common.log(
|
self.web.common.log(
|
||||||
"ReceiveModeRequest",
|
"ReceiveModeRequest",
|
||||||
"__init__",
|
"__init__",
|
||||||
f"saved message to {local_path}",
|
f"saved message to {self.message_filename}",
|
||||||
)
|
)
|
||||||
print(f"Received: {local_path}")
|
print(f"\nReceived: {self.message_filename}")
|
||||||
|
|
||||||
self.tell_gui_request_started()
|
self.tell_gui_request_started()
|
||||||
|
|
||||||
|
@ -491,6 +491,7 @@ class ReceiveModeRequest(Request):
|
||||||
"id": self.history_id,
|
"id": self.history_id,
|
||||||
"content_length": self.content_length,
|
"content_length": self.content_length,
|
||||||
"includes_text": self.includes_text,
|
"includes_text": self.includes_text,
|
||||||
|
"message_filename": self.message_filename,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.web.receive_mode.uploads_in_progress.append(self.history_id)
|
self.web.receive_mode.uploads_in_progress.append(self.history_id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue