mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-25 15:29:42 -05:00
Use microseconds for Receive Mode dir/file names
This commit is contained in:
parent
1b259a208d
commit
096178a9e6
@ -378,7 +378,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%f")
|
||||||
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
|
||||||
)
|
)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import glob
|
||||||
import pytest
|
import pytest
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
@ -35,15 +36,15 @@ class TestReceive(GuiBaseTest):
|
|||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
date_dir = now.strftime("%Y-%m-%d")
|
date_dir = now.strftime("%Y-%m-%d")
|
||||||
if identical_files_at_once:
|
|
||||||
time_dir = now.strftime("%H%M%S-1")
|
|
||||||
else:
|
|
||||||
time_dir = now.strftime("%H%M%S")
|
time_dir = now.strftime("%H%M%S")
|
||||||
receive_mode_dir = os.path.join(
|
receive_mode_dir = os.path.join(
|
||||||
tab.settings.get("receive", "data_dir"), date_dir, time_dir
|
tab.settings.get("receive", "data_dir"), date_dir, time_dir
|
||||||
)
|
)
|
||||||
expected_filename = os.path.join(receive_mode_dir, expected_basename)
|
# The directories have microseconds in the name, so we need
|
||||||
if os.path.exists(expected_filename):
|
# to use globbing against directory names containing the same
|
||||||
|
# second in order to try to find the file.
|
||||||
|
for path in glob.glob(receive_mode_dir + "*"):
|
||||||
|
if os.path.exists(os.path.join(path, expected_basename)):
|
||||||
exists = True
|
exists = True
|
||||||
break
|
break
|
||||||
now = now - timedelta(seconds=1)
|
now = now - timedelta(seconds=1)
|
||||||
@ -83,13 +84,14 @@ class TestReceive(GuiBaseTest):
|
|||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
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")
|
||||||
expected_filename = os.path.join(
|
expected_estimated_filename = os.path.join(
|
||||||
tab.settings.get("receive", "data_dir"),
|
tab.settings.get("receive", "data_dir"),
|
||||||
date_dir,
|
date_dir,
|
||||||
f"{time_dir}-message.txt",
|
f"{time_dir}*-message.txt",
|
||||||
)
|
)
|
||||||
if os.path.exists(expected_filename):
|
for path in glob.glob(expected_estimated_filename):
|
||||||
with open(expected_filename) as f:
|
if os.path.exists(path):
|
||||||
|
with open(path) as f:
|
||||||
assert f.read() == message
|
assert f.read() == message
|
||||||
|
|
||||||
exists = True
|
exists = True
|
||||||
|
Loading…
Reference in New Issue
Block a user