Closed Bug 1657663 Opened 4 years ago Closed 4 years ago

Improve resolution of file times as set/get by nsLocalFile on unix

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: mail, Assigned: mail)

Details

Attachments

(2 files)

The current Unix implementation of nsLocalFile::SetLastModifiedTime sets file times with the legacy utime (2) system call, which is limited to a resolution of 1 second. Similarly when accessing these values with nsLocalFile::GetLastModifiedTime, the implementation uses the legacy stat.st_atime and stat.st_mtime members which represent file access/modification times in seconds since epoch.

The current implementation is problematic, since these APIs accept a PRTime value specified in milliseconds since epoch. The caller will have its set/get values silently truncated to the closest second.

We can update the implementations of SetLastModifiedTime and GetLastModifiedTime to use the utimes (2) family of system calls instead, which allow for up to 1 microsecond resolution with the timeval struct.

This change will also bring the unix implementation of nsLocalFile in line with the windows implementation, which does not truncate the file modification times during get/set operations.

Assignee: nobody → krourke

This change updates the unix implementation of nsLocalFile
Set/GetLastModifiedTime methods to improve the precision of file modification
times from a 1 second resolution to a 1 millisecond resolution.

Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/60059f7d5c46
Improve timestamp precision for nsLocalFileUnix r=froydnj,barret

This changes fixes some failing extension tests on unixes. These failures were
caused by a mismatch in time precision used by nsIFile and OS.File's
implementations.

The fixes are as follows:

  1. Use IOUtils (the C++ port of OS.File) methods where possible.
  2. Update the OS.File.setDates implementation to use a higher time precision
    when setDates is called. This is an intermediate measure until IOUtils
    itself has the ability to update file times.

Depends on D86238

Flags: needinfo?(krourke)
Attachment #9169635 - Attachment is obsolete: true
Attachment #9169635 - Attachment is obsolete: false
Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f9c823fa14ba
Improve timestamp precision for nsLocalFileUnix r=froydnj,barret
https://hg.mozilla.org/integration/autoland/rev/e3dd5b6b4fbd
Update OS.File.setDates precision and fix failing extension tests r=barret,mixedpuppy
Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/724b9714bc47
Improve timestamp precision for nsLocalFileUnix r=froydnj,barret
https://hg.mozilla.org/integration/autoland/rev/f8d98e224ebc
Update OS.File.setDates precision and fix failing extension tests r=barret,mixedpuppy
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: