diff --git a/oml/item/models.py b/oml/item/models.py index b3e6a9c..b3a931d 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -570,8 +570,12 @@ class Item(db.Model): for f in self.files.all(): path = f.fullpath() if os.path.exists(path): - os.unlink(path) - remove_empty_folders(os.path.dirname(path)) + try: + os.chmod(path, stat.S_IWRITE) + os.unlink(path) + remove_empty_folders(os.path.dirname(path)) + except: + pass state.db.session.delete(f) user = state.user() if user in self.users: diff --git a/oml/item/scan.py b/oml/item/scan.py index fb2cc35..7d117b1 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -5,6 +5,7 @@ from datetime import datetime import os import shutil +import stat import time import ox @@ -235,7 +236,11 @@ def run_import(options=None): file.move() added += 1 elif options.get('mode') == 'move': - os.unlink(f_import) + try: + os.chmod(f_import, stat.S_IWRITE) + os.unlink(f_import) + except: + pass if listname: listitems.append(file.item.id) if state.activity.get('cancel'): diff --git a/oml/tor.py b/oml/tor.py index 05f4a75..3b93e5f 100644 --- a/oml/tor.py +++ b/oml/tor.py @@ -87,6 +87,7 @@ DirReqStatistics 0 cwd = os.path.dirname(tor) while self.running: if sys.platform == 'win32': + cwd = settings.data_path startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE diff --git a/oml/update.py b/oml/update.py index 76d9bf0..d348f11 100644 --- a/oml/update.py +++ b/oml/update.py @@ -179,7 +179,7 @@ def install(): if os.path.exists(module): move(module, module_old) move(os.path.join(new, module), module) - if os.path.exists(module_old): + if platform != 'win32' and os.path.exists(module_old): rmtree(module_old) rmtree(new) else: