eyeonus / Trade-Dangerous

Mozilla Public License 2.0
96 stars 31 forks source link

Windows can't access file during buildCache() #123

Closed eyeonus closed 2 months ago

eyeonus commented 2 months ago

Running trade import -P eddblink -O all,skipvend on Win11:

  File "C:\Program Files\Python312\Lib\site-packages\tradedangerous\plugins\eddblink_plug.py", line 510, in run
    cache.buildCache(self.tdb, self.tdenv)
  File "C:\Program Files\Python312\Lib\site-packages\tradedangerous\cache.py", line 977, in buildCache
    dbPath.rename(backupPath)
  File "C:\Program Files\Python312\Lib\pathlib.py", line 1363, in rename
    os.rename(self, target)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'E:\\Game Tools\\trade\\data\\TradeDangerous.db' -> 'E:\\Game Tools\\trade\\data\\TradeDangerous.old'

I have no idea, someone help.

Tromador commented 2 months ago

Actually, same with trade import -P eddblink and no options.

kfsone commented 2 months ago

Need to ensure the db is closed - I think I have a fix for this in the branch.

eyeonus commented 2 months ago

Need to ensure the db is closed - I think I have a fix for this in the branch.

From running on your branch:

  File "/run/media/Library/Documents/eclipse-workspace/Trade-Dangerous/tradedangerous/plugins/eddblink_plug.py", line 479, in run
    self.tdb.reloadCache()
  File "/run/media/Library/Documents/eclipse-workspace/Trade-Dangerous/tradedangerous/tradedb.py", line 700, in reloadCache
    cache.buildCache(self, self.tdenv)
  File "/run/media/Library/Documents/eclipse-workspace/Trade-Dangerous/tradedangerous/cache.py", line 1001, in buildCache
    tempDB.commit()
sqlite3.ProgrammingError: Cannot operate on a closed database.
kfsone commented 2 months ago

You may need to git pull --force as I rebased at one point (line 1001 in my local pull is a "tdenv.NOTE")

eyeonus commented 2 months ago

I haven't merged your PR yet, I'm waiting for you to decide it's ready. I'll take care of any conflicts at that point.