1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 16:27:13 +03:00

12 Commits

Author SHA1 Message Date
Athanasius
bc33bf1b19 Attempt to get develop back to code state before rebase on main. 2021-04-01 14:45:51 +01:00
Athanasius
74afcb085a JournalLock: Catch when journal_dir is None
* If it's None then set journal_dir_path to None as well.  Setting '' or
  nothing results in '.' (CWD), which could cause other issues.
* As we do this in three places, it's in a helper function.
* New JournalLockResult.JOURNALDIR_IS_NONE to signal this.
* Fix checking of return from obtain_lock() to specifically reference
  JournalLockResult.ALREADY_LOCKED.
2021-04-01 14:45:51 +01:00
Athanasius
e777727658 Change JournalLock.obtain_lock() return to an Enum.
This way we can tell the difference between:

1. This process obtained the lock.
2. Another process has the lock.
3. We couldn't get the lock due to not being able to open the lock file
   read-write.

Case 3 is currently also returned if the configured journal directory
doesn't exist.  This will be the case on any MacOS system that never had
the game running.  Likely given the OS hasn't been supported for the
game in years now.

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:50 +01:00
Athanasius
9a82874c7e journal_lock: Now fully type-hinted. 2021-04-01 14:45:49 +01:00
Athanasius
6be73dc50e journal_lock: Fix import order & add/expand docstrings 2021-04-01 14:45:49 +01:00
Athanasius
d39c0521da Move JournalLock class into its own file
Closes #891

# Conflicts:
#	journal_lock.py
#	monitor.py
2021-04-01 14:45:49 +01:00
Athanasius
f1c50faafa logger.exception() doesn't need exc_info 2021-03-15 15:58:18 +00:00
Athanasius
fa49159de5 JournalLock: Catch when journal_dir is None
* If it's None then set journal_dir_path to None as well.  Setting '' or
  nothing results in '.' (CWD), which could cause other issues.
* As we do this in three places, it's in a helper function.
* New JournalLockResult.JOURNALDIR_IS_NONE to signal this.
* Fix checking of return from obtain_lock() to specifically reference
  JournalLockResult.ALREADY_LOCKED.
2021-03-15 11:20:46 +00:00
Athanasius
1cd0392527 Record if JournalLock.obtain_lock() succeeded, use in release_lock()
In the scenario of the default Journals location not even existing the
user needs might update it to a network mount.  When they do so we
attempt, and fail, to unlock the old location, despite it not being
locked.

So now we have this boolean so we know if we should even attempt
unlocking.
2021-03-13 22:32:40 +00:00
Athanasius
60c67723ca Change JournalLock.obtain_lock() return to an Enum.
This way we can tell the difference between:

1. This process obtained the lock.
2. Another process has the lock.
3. We couldn't get the lock due to not being able to open the lock file
   read-write.

Case 3 is currently also returned if the configured journal directory
doesn't exist.  This will be the case on any MacOS system that never had
the game running.  Likely given the OS hasn't been supported for the
game in years now.
2021-03-13 22:32:33 +00:00
Athanasius
84590720ef journal_lock: Revert to deprecated config.get() method
Those changes are only in `develop` at this stage.
2021-03-12 12:52:15 +00:00
Athanasius
c565422b54 Actually add journal_lock.py into this branch
I'd `git show develop:journal_lock.py > journal_lock.py` a copy in
before, but forgot to commit it, and then removed it when checking out
another branch complained.  D'oh!
2021-03-12 12:49:17 +00:00