local clean
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func shouldSkipDownload(rootFolder string, item S3Item) bool {
|
||||
path := filepath.Join(rootFolder, item.Key)
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if item.Size != nil {
|
||||
return info.Size() == *item.Size
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func createFileIfNotExistOrDiffer(rootFolder string, item S3Item, content []byte) error {
|
||||
path := filepath.Join(rootFolder, item.Key)
|
||||
|
||||
if info, err := os.Stat(path); err == nil {
|
||||
if item.Size != nil && info.Size() == *item.Size {
|
||||
fmt.Printf("\r%s, mar letezik", path)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(path, content, 0o644)
|
||||
}
|
||||
Reference in New Issue
Block a user