From b7081da7fa89a73fefc86c54adde1fdf435c2e0b Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 29 Dec 2018 10:10:07 -0500 Subject: [PATCH] Fix cleanup for nzbToMedia installed as a git submodule Fixes #1473 --- cleanup.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cleanup.py b/cleanup.py index 3f022289..33b379dd 100644 --- a/cleanup.py +++ b/cleanup.py @@ -106,9 +106,7 @@ def clean_folders(*paths): def clean(*paths): """Clean up bytecode and obsolete folders.""" - with WorkingDirectory(module_path()) as cwd: - if cwd.working_directory != cwd.original_directory: - print('Changing to directory:', cwd.working_directory) + def _clean(*paths): print('\n-- Cleaning bytecode --') try: result = clean_bytecode() @@ -124,8 +122,19 @@ def clean(*paths): print(error) else: print(result or 'No folders to clean\n') + + with WorkingDirectory(module_path()) as cwd: + if cwd.working_directory != cwd.original_directory: + print('Changing to directory:', cwd.working_directory) + + if os.path.exists('.git'): + _clean(*paths) + else: + print('Directory is not a git repository') + if cwd.working_directory != cwd.original_directory: print('Returning to directory: ', cwd.original_directory) + print('\n-- Cleanup finished --\n')