From 602eada4308ad5e91f3e5a74ff9df5b4aad27f5b Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 5 Jun 2017 14:21:55 -0400 Subject: [PATCH 1/6] fix delete_all option in file_delete API command --- lbrynet/lbrynet_daemon/Daemon.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 1c097f7fb..7bbc2d5be 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -1547,7 +1547,8 @@ class Daemon(AuthJSONRPCServer): [--name=] Options: - -a : delete file from downloads and delete stored blobs + -a : if there are multiple matching files, allow the deletion + of multiple files. Otherwise do not delete anything. -f : delete only from downloads, do not delete blobs --sd_hash= : delete by file sd hash --file_name : delete by file name in downloads folder @@ -1567,7 +1568,8 @@ class Daemon(AuthJSONRPCServer): if not delete_all: log.warning("There are %i files to delete, use narrower filters to select one", len(lbry_files)) - result = False + response = yield self._render_response(False) + defer.returnValue(response) else: log.warning("Deleting %i files", len(lbry_files)) @@ -1584,6 +1586,7 @@ class Daemon(AuthJSONRPCServer): delete_file=delete_target_file) log.info("Deleted %s (%s)", file_name, utils.short_hash(stream_hash)) result = True + response = yield self._render_response(result) defer.returnValue(response) From 9bf533fc73e1e35240acebb32810bdd42480fe46 Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 5 Jun 2017 16:17:02 -0400 Subject: [PATCH 2/6] fix delete_target_file flag, add longer flag name option --- lbrynet/lbrynet_daemon/Daemon.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 7bbc2d5be..81c9baec0 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -1536,20 +1536,20 @@ class Daemon(AuthJSONRPCServer): @AuthJSONRPCServer.auth_required @defer.inlineCallbacks @AuthJSONRPCServer.flags(delete_target_file='-f', delete_all='-a') - def jsonrpc_file_delete(self, delete_target_file=True, delete_all=False, **kwargs): + def jsonrpc_file_delete(self, delete_target_file=False, delete_all=False, **kwargs): """ Delete a LBRY file Usage: - file_delete [-a | -f] [--sd_hash=] [--file_name=] + file_delete [-a] [-f] [--sd_hash=] [--file_name=] [--stream_hash=] [--claim_id=] [--outpoint=] [--rowid=] [--name=] Options: - -a : if there are multiple matching files, allow the deletion + -a, --delete_all : if there are multiple matching files, allow the deletion of multiple files. Otherwise do not delete anything. - -f : delete only from downloads, do not delete blobs + -f, --delete_target_file : delete file from download directory, instead of just blobs --sd_hash= : delete by file sd hash --file_name : delete by file name in downloads folder --stream_hash= : delete by file stream hash From a1c99594b3eed035eb5ca7dfacdb8a6977732d8a Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 5 Jun 2017 16:17:19 -0400 Subject: [PATCH 3/6] add tests for CLI flags --- lbrynet/lbrynet_daemon/Daemon.py | 11 +++++++---- tests/integration/test_integration.py | 23 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 81c9baec0..a835fbcae 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -2501,22 +2501,25 @@ class Daemon(AuthJSONRPCServer): defer.returnValue(response) @defer.inlineCallbacks - def jsonrpc_cli_test_command(self, pos_arg, pos_args=[], pos_arg2=None, pos_arg3=None): + @AuthJSONRPCServer.flags(a_arg='-a', b_arg='-b') + def jsonrpc_cli_test_command(self, pos_arg, pos_args=[], pos_arg2=None, pos_arg3=None, + a_arg=False, b_arg=False): """ This command is only for testing the CLI argument parsing Usage: - cli_test_command ( | --pos_arg=) + cli_test_command [-a] [-b] ( | --pos_arg=) [...] [--pos_arg2=] [--pos_arg3=] Options: + -a, --a_arg : a arg + -b, --b_arg : b arg , --pos_arg2= : pos arg 2 , --pos_arg3= : pos arg 3 - Returns: pos args """ - out = (pos_arg, pos_args, pos_arg2, pos_arg3) + out = (pos_arg, pos_args, pos_arg2, pos_arg3, a_arg, b_arg) response = yield self._render_response(out) defer.returnValue(response) diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index ef6fd1797..521d93844 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -77,21 +77,36 @@ class TestIntegration(unittest.TestCase): out,err = lbrynet_cli(['cli_test_command','1']) out = json.loads(out) - self.assertEqual([1,[],None,None], out) + self.assertEqual([1,[],None,None,False,False], out) out,err = lbrynet_cli(['cli_test_command','1','--pos_arg2=1']) out = json.loads(out) - self.assertEqual([1,[],1,None], out) + self.assertEqual([1,[],1,None,False,False], out) out,err = lbrynet_cli(['cli_test_command','1', '--pos_arg2=2','--pos_arg3=3']) out = json.loads(out) - self.assertEqual([1,[],2,3], out) + self.assertEqual([1,[],2,3,False,False], out) out,err = lbrynet_cli(['cli_test_command','1','2','3']) out = json.loads(out) # TODO: variable length arguments don't have guess_type() on them - self.assertEqual([1,['2','3'],None,None], out) + self.assertEqual([1,['2','3'],None,None,False,False], out) + + + out,err = lbrynet_cli(['cli_test_command','1','-a']) + out = json.loads(out) + self.assertEqual([1,[],None,None,True,False], out) + + out,err = lbrynet_cli(['cli_test_command','1','--a_arg']) + out = json.loads(out) + self.assertEqual([1,[],None,None,True,False], out) + + + out,err = lbrynet_cli(['cli_test_command','1','-a','-b']) + out = json.loads(out) + self.assertEqual([1,[],None,None,True,True], out) + def test_status(self): From ae9a6b524fad76a4202ebc44e671081d18252966 Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 5 Jun 2017 16:28:32 -0400 Subject: [PATCH 4/6] add changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e815cdf3..b1d3abe9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ at anytime. ### Fixed * Race condition from improper initialization and shutdown of the blob manager database * Various fixes for GetStream class used in API command get + * Download analytics error + * Fixed flag options in file_delete API command + * ### Deprecated * From 69dacffc7a5bfeedff52f137b8bd191dfa90b668 Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Tue, 6 Jun 2017 15:01:05 -0400 Subject: [PATCH 5/6] rename delete_target_file to delete_from_download_dir, remove -a delete_all option --- lbrynet/lbrynet_daemon/Daemon.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index a835fbcae..b255c2f5a 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -1535,28 +1535,30 @@ class Daemon(AuthJSONRPCServer): @AuthJSONRPCServer.auth_required @defer.inlineCallbacks - @AuthJSONRPCServer.flags(delete_target_file='-f', delete_all='-a') - def jsonrpc_file_delete(self, delete_target_file=False, delete_all=False, **kwargs): + @AuthJSONRPCServer.flags(delete_from_download_dir='-f', delete_all='--delete_all') + def jsonrpc_file_delete(self, delete_from_download_dir=False, delete_all=False, **kwargs): """ Delete a LBRY file Usage: - file_delete [-a] [-f] [--sd_hash=] [--file_name=] + file_delete [-f] [--delete_all] [--sd_hash=] [--file_name=] [--stream_hash=] [--claim_id=] [--outpoint=] [--rowid=] [--name=] Options: - -a, --delete_all : if there are multiple matching files, allow the deletion - of multiple files. Otherwise do not delete anything. - -f, --delete_target_file : delete file from download directory, instead of just blobs - --sd_hash= : delete by file sd hash - --file_name : delete by file name in downloads folder - --stream_hash= : delete by file stream hash - --claim_id= : delete by file claim id - --outpoint= : delete by file claim outpoint - --rowid= : delete by file row id - --name= : delete by associated name claim of file + -f, --delete_from_download_dir : delete file from download directory, + instead of just deleting blobs + --delete_all : if there are multiple matching files, + allow the deletion of multiple files. + Otherwise do not delete anything. + --sd_hash= : delete by file sd hash + --file_name : delete by file name in downloads folder + --stream_hash= : delete by file stream hash + --claim_id= : delete by file claim id + --outpoint= : delete by file claim outpoint + --rowid= : delete by file row id + --name= : delete by associated name claim of file Returns: (bool) true if deletion was successful @@ -1583,7 +1585,7 @@ class Daemon(AuthJSONRPCServer): if lbry_file.claim_id in self.streams: del self.streams[lbry_file.claim_id] yield self.lbry_file_manager.delete_lbry_file(lbry_file, - delete_file=delete_target_file) + delete_file=delete_from_download_dir) log.info("Deleted %s (%s)", file_name, utils.short_hash(stream_hash)) result = True From 4c22362cc1c1d9c426f504e6eb76b6fb52e1574d Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 12 Jun 2017 19:46:31 -0400 Subject: [PATCH 6/6] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1d3abe9a..6af897d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ at anytime. * Support resolution of multiple uris with `resolve`, all results are keyed by uri * Add `error` responses for failed resolves * Add `claim_list_by_channel`, supports multiple channel resolution + * Rename delete_target_file argument of delete API command to delete_from_download_dir + * Rename delete_all CLI flag -a to --delete_all ### Fixed * Race condition from improper initialization and shutdown of the blob manager database