[eDVBMetaParser] Uses inode change time as fallback file creation time

Issue #638 resolved
prl created an issue

If there is no .ts.meta file for a recording the eDVBMetaParser::parseFile(), eDVBMetaParser::parseFile() and eDVBMetaParser::parseRecordings() call getctime() for a fallback recording creation time, eDVBMetaParser::m_time_create.

However, getctime() calls stat() and uses struct stat.st_ctime to set the fallback. st_ctime, though, is not the file creation time, but is the file's inode modification time, which can never be older than the file's data modification time st_ctime. st_ctime is updated by various operations that do not modify its data, like renaming the file, moving the file to a new directory or changing its permissions.

Although also not the file creation time, struct stat.st_mtime, the files "last modified" time, would be a better choice for the fallback creation time.

Replication steps

Create a throwaway recording in a filename format where the recording start time cannot be extracted from its filename in the current firmware, e.g. before starting the recording, set MENU>Setup>TV>Recording settings>Composition of recording names to "Event name first". (See also bug #637).

When it completes, in the media selection screen, check that its recording time is correct and exit media selection.

Delete its .ts.meta file.

View the file in the media selection screen (MEDIA from live TV), and note that its displayed "recording time" is now the completion time for the recording and exit media selection.

Wait a few minutes and then use chmod on the commandline to change the recording file's permissions (a chmod command that actually results in no change, like chmod u+r is enough to update st_ctime).

Delete its .ts.meta file.

View the file in the media selection screen (MEDIA from live TV), and note that its displayed "recording time" is now the time the file's permissions were changed.

Comments (1)

  1. Peter Urbanec

    Fix bug #638: [eDVBMetaParser] Uses inode change time as fallback file creation time

    Rename static function getctime() to getmtime(), and have it return s.st_mtime instead of s.st_ctime.

    Use getmtime() to calculate the fallback m_time_create so that it uses the last modified time instaed of the inode changed time.

    → <<cset 44864836b0e7>>

  2. Log in to comment