From 0fc5c42aba56954f79fd25b04e100fc58d3b9b71 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 30 Jun 2012 19:03:53 +0200 Subject: [PATCH] Give error when datadir in appdir --- couchpotato/core/_base/_core/main.py | 7 +++++++ couchpotato/core/_base/updater/main.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/couchpotato/core/_base/_core/main.py b/couchpotato/core/_base/_core/main.py index bac1efed..2e5bc843 100644 --- a/couchpotato/core/_base/_core/main.py +++ b/couchpotato/core/_base/_core/main.py @@ -43,6 +43,7 @@ class Core(Plugin): addEvent('app.base_url', self.createBaseUrl) addEvent('app.api_url', self.createApiUrl) addEvent('app.version', self.version) + addEvent('app.load', self.checkDataDir) addEvent('setting.save.core.password', self.md5Password) addEvent('setting.save.core.api_key', self.checkApikey) @@ -54,6 +55,12 @@ class Core(Plugin): def checkApikey(self, value): return value if value and len(value) > 3 else uuid4().hex + def checkDataDir(self): + if Env.get('app_dir') in Env.get('data_dir'): + log.error('You should NOT use your CouchPotato directory to save your settings in. Files will get overwritten or be deleted.') + + return True + def available(self): return jsonified({ 'succes': True diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index f148b4bd..3717b90e 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -305,6 +305,13 @@ class SourceUpdater(BaseUpdater): except Exception, e: log.error('Failed overwriting file: %s', e) + if Env.get('app_dir') not in Env.get('data_dir'): + for still_exists in existing_files: + try: + os.remove(still_exists) + except: + log.error('Failed removing non-used file: %s', traceback.format_exc()) + def removeDir(self, path): try: