Save current timeshift event sometimes saves the event's .sc file

Issue #490 resolved
prl created an issue

If InfoBarTimeshift.SaveTimeshift() is called without an explicit timeshift file argument, and in the timeshift buffer directory (/media/hdd/timeshift) the file timeshift.XXXXXX.sc is listed after timeshift.XXXXXX (the .ts file) when os.listdir("/media/hdd/timeshift") is called by SaveTimeshift() and timeshift.XXXXXX.sc has been updated in the last 5 seconds, then timeshift.XXXXXX.sc will be used as the saved timeshift buffer's .ts file, instead of timeshift.XXXXXX, which is the actual TS file.

InfoBarTimeshift.SaveTimeshift() is called without an explicit timeshift file argument in 5 places in InfoBarTimeshift.

The ordering of timeshift.XXXXXX.sc after timeshift.XXXXXX happens about 50% of the time, and as the active timeshift buffer, timeshift.XXXXXX.sc has almost aways been updated within the last 5 seconds.

Replication steps

Change channels and wait for timeshift to start on the channel.

Check that timeshift.XXXXXX.sc is listed in the directory after timeshift.XXXXXX. If not, change channels again, and repeat until it is. A few channel changes will be needed.

The order of the directory entries can't be tested using ls -f, because the Busybox ls doesn't support that option. The following python command-line command can check the ordering:

python -c 'import os; print os.listdir("/media/hdd/timeshift/")'

If timeshift.XXXXXX.sc appears in the printed list after timeshift.XXXXXX, then the ordering criterion for the bug is met.

Start a timeshift save of the current event using REC>Select an event to save>Current Event: event name.

Identify the timeshift files uniquely by using the command-line:

ls -li /media/hdd/timeshift/timeshift*

The inode number in the leftmost column of the listing is uniquely identifies the file on the HDD volume.

Enter shutdown using the short-POWER button (the POWER button mapping in MENU>Setup>System>Button settings>Action on short POWER may need to be changed to do this).

In the "You have chosen..." popup, select "Save timeshift and stop recording" to enter standby.

In the command-line interface, use:

ls -li /media/hdd/movie/*part_of_event_name*.ts

to list the saved timeshift event. It will have the same inode number as the timeshift.XXXXXX.sc file, because the wrong file has been linked. It will have a hard link to the corresponding pts_livebuffer_N.sc file in /media/hdd/timeshift. THis can be confirmwd by the ls -li inode number and link count for the two files.

Restart from standby with POWER.

Enter the media player with MEDIA.

Navigate to the saved timeshift file. It will list as empty or as a much smaller size than expected, and with duration 0:00 (or possibly some improbable duration). It will not play.

This is not the only execution path that causes this problem.

Comments (1)

  1. Peter Urbanec

    Fix Bug #490: Save current timeshift event sometimes saves the event's .sc file

    [InfoBarTimeshift]

    In SaveTimeshift(), when timeshiftfile is None only consider timeshift.XXXXXX filenames as a timeshift file candidates, rather than both timeshift.XXXXXX and timeshift.XXXXXX.sc filenames.

    → <<cset d4a6e84b7462>>

  2. Log in to comment