mirror of
https://github.com/tw93/Mole.git
synced 2026-02-13 01:00:13 +00:00
Reconstruct the structure of go
This commit is contained in:
@@ -56,14 +56,19 @@ func deletePathWithProgress(root string, counter *int64) (int64, error) {
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return count, err
|
||||
// Track walk error separately
|
||||
if err != nil && firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
|
||||
if err := os.RemoveAll(root); err != nil {
|
||||
return count, err
|
||||
// Try to remove remaining directory structure
|
||||
// Even if this fails, we still report files deleted
|
||||
if removeErr := os.RemoveAll(root); removeErr != nil {
|
||||
if firstErr == nil {
|
||||
firstErr = removeErr
|
||||
}
|
||||
}
|
||||
|
||||
// Return the first error encountered during deletion if any
|
||||
// Always return count (even if there were errors), along with first error
|
||||
return count, firstErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user