Handle deleting a directory

This commit is contained in:
Dane Everitt 2020-08-23 14:34:42 -07:00
parent 37fbae0fcd
commit 3b33e803e3
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -621,12 +621,15 @@ func (fs *Filesystem) Delete(p string) error {
fs.Server.Log().WithField("error", err).WithField("path", resolved).Warn("error while attempting to stat file before deletion") fs.Server.Log().WithField("error", err).WithField("path", resolved).Warn("error while attempting to stat file before deletion")
} }
} else { } else {
// TODO: handle deleting a directory by finding its current size. if !st.IsDir() {
go func (st os.FileInfo) { atomic.SwapInt64(&fs.diskUsage, -st.Size())
if !st.IsDir() { } else {
atomic.SwapInt64(&fs.diskUsage, fs.diskUsage - st.Size()) go func(st os.FileInfo, resolved string) {
} if s, err := fs.DirectorySize(resolved); err == nil {
}(st) atomic.AddInt64(&fs.diskUsage, -s)
}
}(st, resolved)
}
} }
return os.RemoveAll(resolved) return os.RemoveAll(resolved)