diff --git a/cli/onionshare_cli/__init__.py b/cli/onionshare_cli/__init__.py index d84a1eec..8824a0c3 100644 --- a/cli/onionshare_cli/__init__.py +++ b/cli/onionshare_cli/__init__.py @@ -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") diff --git a/cli/onionshare_cli/mode_settings.py b/cli/onionshare_cli/mode_settings.py index 90bcaf07..77d1d643 100644 --- a/cli/onionshare_cli/mode_settings.py +++ b/cli/onionshare_cli/mode_settings.py @@ -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, diff --git a/cli/onionshare_cli/web/send_base_mode.py b/cli/onionshare_cli/web/send_base_mode.py index ca79b99f..3ef6231c 100644 --- a/cli/onionshare_cli/web/send_base_mode.py +++ b/cli/onionshare_cli/web/send_base_mode.py @@ -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 ),