summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2021-04-30 15:53:23 -0700
committerMicah Lee <micah@micahflee.com>2021-04-30 15:53:23 -0700
commit95e6985f865a57b97d40c8a7c35c77505d0750d2 (patch)
tree227ebef14529e0f58828567643bce7f8a832999a
parent47e02d781a5fb348fe2fb728300a73e3de37dfca (diff)
downloadonionshare-95e6985f865a57b97d40c8a7c35c77505d0750d2.tar.gz
onionshare-95e6985f865a57b97d40c8a7c35c77505d0750d2.zip
Remove periods from receive mode time folder names, and save the message outside of the time folder
-rw-r--r--cli/onionshare_cli/web/receive_mode.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/cli/onionshare_cli/web/receive_mode.py b/cli/onionshare_cli/web/receive_mode.py
index 5a8ff27c..79d58486 100644
--- a/cli/onionshare_cli/web/receive_mode.py
+++ b/cli/onionshare_cli/web/receive_mode.py
@@ -377,7 +377,7 @@ class ReceiveModeRequest(Request):
# Figure out what files should be saved
now = datetime.now()
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.web.settings.get("receive", "data_dir"), date_dir, time_dir
)
@@ -425,6 +425,9 @@ class ReceiveModeRequest(Request):
)
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 self.upload_error:
return
@@ -461,18 +464,15 @@ class ReceiveModeRequest(Request):
if text_message:
if text_message.strip() != "":
self.includes_text = True
- filename = "message.txt"
- local_path = os.path.join(self.receive_mode_dir, filename)
-
- with open(local_path, "w") as f:
+ with open(self.message_filename, "w") as f:
f.write(text_message)
self.web.common.log(
"ReceiveModeRequest",
"__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()
@@ -491,6 +491,7 @@ class ReceiveModeRequest(Request):
"id": self.history_id,
"content_length": self.content_length,
"includes_text": self.includes_text,
+ "message_filename": self.message_filename,
},
)
self.web.receive_mode.uploads_in_progress.append(self.history_id)