summaryrefslogtreecommitdiff
path: root/doIncoming.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-10 12:13:24 -0500
committerJeff Carr <[email protected]>2025-10-10 16:22:19 -0500
commita71d41b045612131597931baffe2097db2b659d3 (patch)
tree9d7fb237128f4644cdfa53bfefc857ddb260daad /doIncoming.go
parente66e515eb9a65aaa1743ddbac4b77ffba996af7f (diff)
it's kinda limping along now
Diffstat (limited to 'doIncoming.go')
-rw-r--r--doIncoming.go35
1 files changed, 21 insertions, 14 deletions
diff --git a/doIncoming.go b/doIncoming.go
index f077db7..9f2202d 100644
--- a/doIncoming.go
+++ b/doIncoming.go
@@ -18,6 +18,7 @@ func doIncoming() (string, error) {
log.Info(p.Package, p.Filename)
}
+ var counter int
err := filepath.Walk("pool", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
@@ -38,24 +39,30 @@ func doIncoming() (string, error) {
log.Printf("%s move incoming oldname %s newname: %s\n", found.Package, path, newfilename)
log.Fatal("Failed to create destination directory: %v", err)
}
- if config.Exists(newfilename) {
- olddata, _ := os.ReadFile(path)
- newdata, _ := os.ReadFile(newfilename)
- oldmd5 := md5.Sum(olddata)
- newmd5 := md5.Sum(newdata)
- if oldmd5 == newmd5 {
- log.Info("files are the same", md5.Sum(olddata), md5.Sum(newdata))
- } else {
- shell.RunVerbose([]string{"dpkg", "-I", path})
- shell.RunVerbose([]string{"dpkg", "-I", newfilename})
- log.Printf("different checksums: %s %s\n", path, newfilename)
- log.Printf("md5sum old %x vs new %x\n", md5.Sum(olddata), md5.Sum(newdata))
+ if !argv.Force {
+ if config.Exists(newfilename) {
+ olddata, _ := os.ReadFile(path)
+ newdata, _ := os.ReadFile(newfilename)
+ oldmd5 := md5.Sum(olddata)
+ newmd5 := md5.Sum(newdata)
+ if oldmd5 == newmd5 {
+ log.Info("files are the same", md5.Sum(olddata), md5.Sum(newdata))
+ } else {
+ shell.RunVerbose([]string{"dpkg", "-I", path})
+ shell.RunVerbose([]string{"dpkg", "-I", newfilename})
+ log.Printf("different checksums: %s %s\n", path, newfilename)
+ log.Printf("md5sum old %x vs new %x\n", md5.Sum(olddata), md5.Sum(newdata))
+ }
+ // return "file already exists. use --force to replace", errors.New("duplicate .deb in incoming/")
+ me.sh.GoodExit("file already exists. use --force to replace")
}
- me.sh.BadExit("file already exists", nil)
}
os.Rename(path, newfilename)
log.Printf("%s moved incoming oldname %s newname: %s\n", found.Package, path, newfilename)
- me.sh.GoodExit("file moved")
+ counter += 1
+ if counter > 100 {
+ me.sh.GoodExit("file moved")
+ }
return nil
}
log.Info("already processed", path)