git-lfs/lfshttp
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
..
standalone fs: be a little less aggressive with cleanup 2021-04-30 14:36:06 +00:00
body.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs_darwin.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs_nix.go Make lfshttp package builds more portable 2021-04-14 18:28:10 +00:00
certs_test.go lfshttp: cache clients based on host and access type 2019-12-09 15:35:52 +00:00
certs_windows.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
certs.go Cert dir/file access: translate cygwin path. 2021-04-09 10:56:27 +02:00
client_test.go lfshttp: support http.version 2019-10-29 19:47:20 +00:00
client.go t: add test for download gzip transport compression 2020-12-14 20:05:43 +00:00
cookies.go Use different parser for cookiejar files 2019-10-27 16:48:15 -05:00
endpoint.go Allow literal local paths as remotes 2020-05-06 13:56:40 +00:00
errors.go Add integration tests; check other places where 429 could occur 2019-01-07 12:27:02 +03:00
lfshttp.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
proxy_test.go lfshttp/proxy: consider scheme of request URL when choosing proxy 2021-02-03 20:27:39 +00:00
proxy.go lfshttp/proxy: consider scheme of request URL when choosing proxy 2021-02-03 20:27:39 +00:00
retries_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
retries.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
ssh_test.go Merge branch 'master' into lfshttp 2018-09-14 11:42:19 -07:00
ssh.go Use subprocess for invoking all commands 2020-12-21 22:19:04 +00:00
stats_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
stats.go Fix Typos 2019-07-24 07:17:40 +00:00
verbose_test.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00
verbose.go lfsapi: extract new lfshttp package 2018-09-11 14:51:29 -07:00