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:
parent
28696afe9f
commit
ee362cd707
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user