Temporary and partial files should have 0666 permissions

Bug #1013924 reported by Jason Gerard DeRose
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
FileStore
Fix Released
High
Jason Gerard DeRose

Bug Description

ext4 is the recommended filesystem to use with Dmedia, including on removable drives. As FileStore aggressively uses ext4 fallocate() whenever it can, the performance benefit is just too good to turn down.

However, ext4 can be a touch annoying on removable drives when sharing between different users, or when the same user happens to have a different numeric ID on different computers. This is why directories in the FileStore layout all have 0777 permissions and canonical files have 0444 permissions.

The one place we don't yet do the right thing is with temporary and partial files. As it stands now, a user with a different numeric ID wont be able to resume a download/upload, nor will they be able to purge stale temporary files. The fix is to have FileStore.allocate_tmp() and FileStore.allocate_partial() to set 0666 permissions.

The reason I'm doing this now is that when a FileStore is first attached in Dmedia, we should really purge any stale temporary files found in .dmedia/tmp/ so they don't accumulate over time.

On POSIX systems, os.rename() is atomic, meaning a file is always well defined as being either in the FileStore or not, so deleting these temporary files is fair game. Higher-level code in Dmedia should never count a file in .dmedia/tmp/ as having reached a "stored" state in the FileStore.

FYI, we're not going to automatically delete partial or corrupt files.

There's really no reason to ever delete corrupt files... if you're accumulating corrupt files, then your hard drive is failing or you have some other spectacular hardware reliability problem. We'll leave corrupt files for forensic reasons and in case the complete file can be restored from multiple corrupt files (which it can as long as the corruption isn't in the same leaves).

And partial files are tracked specially by Dmedia, so we trust Dmedia to handle partial files correctly.

Related branches

Changed in filestore:
status: In Progress → Fix Committed
Changed in filestore:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.