Skip to content

Fix Flushing of InfoFile#2

Open
prikhi wants to merge 1 commit intobrandyn:mainfrom
prikhi:fix-info-db-creation
Open

Fix Flushing of InfoFile#2
prikhi wants to merge 1 commit intobrandyn:mainfrom
prikhi:fix-info-db-creation

Conversation

@prikhi
Copy link

@prikhi prikhi commented Jan 17, 2026

Modify the InfoFile.flush method, removing the call to undefined temp_filename_for function and replace it with a NamedTemporaryFile.

Instead of renaming the temporary file, we copy it to our desired destination to support cross-filesystem writes and allow the context manager to remove it - os.rename() throws errors when crossing filesystem boundaries.

This fixes errors throw when starting or stopping playback from the directory browser:

Info db changed.  Saving.
Traceback (most recent call last):
  File "/home/prikhi/Projects/vr/xrplay/src/vplay", line 923, in <module>
    run()
    ~~~^^
  File "/home/prikhi/Projects/vr/xrplay/src/vplay", line 921, in run
    VideoPlayer(opts).run(opts.timers)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/prikhi/Projects/vr/xrplay/src/vplay", line 346, in run
    self.close2()               # This closes the current video and all the stuff supporting it.
    ~~~~~~~~~~~^^
  File "/home/prikhi/Projects/vr/xrplay/src/vplay", line 745, in close2
    Info.put(key, info)
    ~~~~~~~~^^^^^^^^^^^
  File "/home/prikhi/Projects/vr/xrplay/src/Info.py", line 56, in put
    db.flush()
    ~~~~~~~~^^
  File "/home/prikhi/Projects/vr/xrplay/src/FileUtils.py", line 91, in flush
    tempname = temp_filename_for(self.filename)
               ^^^^^^^^^^^^^^^^^
NameError: name 'temp_filename_for' is not defined

Modify the `InfoFile.flush` method, removing the call to undefined
`temp_filename_for` function and replace it with a `NamedTemporaryFile`.

Instead of renaming the temporary file, we copy it to our desired
destination to support cross-filesystem writes and allow the context
manager to remove it - `os.rename()` throws errors when crossing
filesystem boundaries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant