git-lfs/fs
brian m. carlson a7f5200b9c
fs: be a little less aggressive with cleanup
When we invoke the file helper to download files from a remote system,
we use the repository's temporary directory in order to make sure we can
quickly and easily rename files into the object store without the need
for a copy, which might be necessary if we used the system temporary
directory.  In many cases, these files we generate are actually hard
links to the remote repository, which means we can cheaply and easily
copy files at maximum speed.  Note, however, that these files don't look
like a normal object ID; instead, they have a name generated by Go's
temporary file code.

However, our current code causes a problem if, during the pull, a file
is checked out and Git causes it to be uselessly cleaned, which happens
in some cases.  That's because our temporary file cleanup code will
remove all files in the temporary directory that don't look like normal
object ID components, and as a result, the clean operation can remove
files that are in use by the fetch.

Instead of immediately purging anything that looks like it's not a valid
object ID, let's wait an hour before pruning any temporary file unless
it's an object that we've already downloaded and verified is in our
object store.

We also need to do one more thing here, which is that we need to ignore
any file that lives in a directory younger than an hour old and adjust
our file helper to create a new directory for its temporary files.  This
is important because if we create a hard link to an object in a remote
repository, it may be older than one hour, and we don't want to prune
those if we're not done yet.

Note that we use a sync.Map to make this as efficient as possible and
avoid the need for many additional stat calls.  Ideally, we won't
actually see an increase in stat calls at all.
2021-04-30 14:36:06 +00:00
..
cleanup.go fs: be a little less aggressive with cleanup 2021-04-30 14:36:06 +00:00
fs_test.go fs: expose repository permissions 2018-12-13 17:51:02 +00:00
fs.go fs: don't panic when using a too-short object ID to push 2020-11-16 15:33:35 +00:00