fs: gracefully handle missing temporary directory

When we are running in a repository where we lack write permissions,
we'll try to clean up temporary files nevertheless.  However, in such a
case, we may not have even been able to create a temporary directory if
one doesn't exist.

With the previous commit, we fixed the hang that occurred here, but we
print an error message like so:

  Error clearing old temp files: stat /tmp/repo/.git/lfs/tmp: no such file or directory

The user probably doesn't care about the fact that we don't have a
temporary directory in this case, and if there were no temporary files
to clean up because there was no temporary directory, then we've already
accomplished our goal.  Let's check for the temporary directory
existing, and if it doesn't, we'll just silently do nothing.
This commit is contained in:
brian m. carlson 2020-08-06 20:48:39 +00:00
parent 28696afe9f
commit ee362cd707
No known key found for this signature in database
GPG Key ID: 2D0C9BC12F82B3A1

@ -16,6 +16,11 @@ func (f *Filesystem) cleanupTmp() error {
return nil
}
// No temporary directory? No problem.
if _, err := os.Stat(tmpdir); err != nil && os.IsNotExist(err) {
return nil
}
var walkErr error
tools.FastWalkDir(tmpdir, func(parentDir string, info os.FileInfo, err error) {
if err != nil {