mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-09 19:27:28 -03:00
Added optional filename logging for individual file downloads
This commit is contained in:
parent
8102c15376
commit
4128cad08f
3 changed files with 25 additions and 2 deletions
|
@ -119,6 +119,13 @@ def main(cwd=None):
|
|||
default=False,
|
||||
help="Share files: Continue sharing after files have been sent (default is to stop sharing)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--log-filenames",
|
||||
action="store_true",
|
||||
dest="log_filenames",
|
||||
default=False,
|
||||
help="Share files: Log individual names of shared files as they are downloaded (requires autostop sharing to be disabled)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--qr",
|
||||
action="store_true",
|
||||
|
@ -204,6 +211,7 @@ def main(cwd=None):
|
|||
disable_files = args.disable_files
|
||||
disable_csp = bool(args.disable_csp)
|
||||
custom_csp = args.custom_csp
|
||||
log_filenames = bool(args.log_filenames)
|
||||
verbose = bool(args.verbose)
|
||||
|
||||
# Verbose mode?
|
||||
|
@ -242,6 +250,7 @@ def main(cwd=None):
|
|||
mode_settings.set("persistent", "mode", mode)
|
||||
if mode == "share":
|
||||
mode_settings.set("share", "autostop_sharing", autostop_sharing)
|
||||
mode_settings.set("share", "log_filenames", log_filenames)
|
||||
if mode == "receive":
|
||||
if data_dir:
|
||||
mode_settings.set("receive", "data_dir", data_dir)
|
||||
|
@ -299,6 +308,10 @@ def main(cwd=None):
|
|||
if persistent_filename:
|
||||
mode_settings.set(mode, "filenames", filenames)
|
||||
|
||||
if autostop_sharing and log_filenames:
|
||||
print("Autostop sharing is enabled, thus individual files cannot be downloaded (or logged). Set both --no-autostop-sharing and --log-filenames for intended functionality.")
|
||||
sys.exit()
|
||||
|
||||
# In receive mode, you must allows either text, files, or both
|
||||
if mode == "receive" and disable_text and disable_files:
|
||||
print("You cannot disable both text and files")
|
||||
|
|
|
@ -48,7 +48,11 @@ class ModeSettings:
|
|||
"autostop_timer": False,
|
||||
"service_id": None,
|
||||
},
|
||||
"share": {"autostop_sharing": True, "filenames": []},
|
||||
"share": {
|
||||
"autostop_sharing": True,
|
||||
"filenames": [],
|
||||
"log_filenames": False,
|
||||
},
|
||||
"receive": {
|
||||
"data_dir": self.build_default_receive_data_dir(),
|
||||
"webhook_url": None,
|
||||
|
|
|
@ -245,8 +245,14 @@ class SendBaseModeWeb:
|
|||
or self.common.platform == "Linux"
|
||||
or self.common.platform == "BSD"
|
||||
):
|
||||
if self.web.settings.get("share", "log_filenames"):
|
||||
filename_str = "{0} - ".format(os.path.basename(file_to_download))
|
||||
else:
|
||||
filename_str = ""
|
||||
|
||||
sys.stdout.write(
|
||||
"\r{0:s}, {1:.2f}% ".format(
|
||||
"\r{0}{1:s}, {2:.2f}% ".format(
|
||||
filename_str,
|
||||
self.common.human_readable_filesize(
|
||||
downloaded_bytes
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue