From cab9041d34733b79673618283ab688b98ebf11dc Mon Sep 17 00:00:00 2001 From: thebigmunch Date: Sun, 14 Feb 2016 21:09:25 -0500 Subject: [PATCH] Fix delete on success check --- gmusicapi_wrapper/gmusicapi_wrapper.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gmusicapi_wrapper/gmusicapi_wrapper.py b/gmusicapi_wrapper/gmusicapi_wrapper.py index beafb37..65296cf 100644 --- a/gmusicapi_wrapper/gmusicapi_wrapper.py +++ b/gmusicapi_wrapper/gmusicapi_wrapper.py @@ -536,11 +536,13 @@ def upload(self, filepaths, enable_matching=False, transcode_quality='320k', del not_uploaded_songs.update(not_uploaded) - if (uploaded or matched) and delete_on_success: - try: - os.remove(filepath) - except: - logger.warning("Failed to remove {} after successful upload".format(filepath)) + success = (uploaded or matched) or (not_uploaded and 'ALREADY_EXISTS' in not_uploaded[filepath]) + + if success and delete_on_success: + try: + os.remove(filepath) + except: + logger.warning("Failed to remove {} after successful upload".format(filepath)) if errors: logger.info("\n\nThe following errors occurred:\n")