Skip to content

Commit

Permalink
Finetune lockfile checks
Browse files Browse the repository at this point in the history
  • Loading branch information
erykjj committed Jan 12, 2025
1 parent 9e2086e commit 3fc6bac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions JWLManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def set_vars():


def check_file(self, file):
self.timer.stop()
if (self.current_archive == '') and (self.modified == False):
if self.load_file(file):
self.file_loaded()
Expand All @@ -174,14 +175,14 @@ def check_file(self, file):
if self.merge_window.choice == 'open':
if self.load_file(file):
self.file_loaded()
else: # 'merge'
else:
self.merge_items(file)
self.timer.start(1000)

def check_lockfile(self):
if os.path.exists(LOCK_FILE):
if os.path.exists(LOCK_FILE) and os.path.getsize(LOCK_FILE) > 0:
with open(LOCK_FILE, 'r+') as lockfile:
file = lockfile.read().strip()
#TODO: check if not empty and pause timer
lockfile.seek(0)
lockfile.truncate()
if Path(file).suffix == '.jwlibrary':
Expand Down Expand Up @@ -3289,7 +3290,7 @@ def get_language():
break
if args['archive']:
sys.argv.append(args['archive'])
if os.path.exists(LOCK_FILE): #TODO: check if empty
if os.path.exists(LOCK_FILE) and os.path.getsize(LOCK_FILE) == 0:
print(LOCK_FILE)
if len(sys.argv) > 1 and os.path.exists(sys.argv[-1]):
write_lockfile(sys.argv[-1])
Expand Down

0 comments on commit 3fc6bac

Please sign in to comment.