summaryrefslogtreecommitdiff
path: root/doIncoming.go
diff options
context:
space:
mode:
Diffstat (limited to 'doIncoming.go')
-rw-r--r--doIncoming.go93
1 files changed, 46 insertions, 47 deletions
diff --git a/doIncoming.go b/doIncoming.go
index f1b8cb9..636aa14 100644
--- a/doIncoming.go
+++ b/doIncoming.go
@@ -29,57 +29,56 @@ func doIncoming(pb *zoopb.Packages) (string, error) {
counter += 1
}
newcount += 1
- if strings.HasPrefix(path, "pool/main") {
- _, filename := filepath.Split(path)
- parts := strings.Split(filename, "_")
- if len(parts) != 3 {
- // todo: add more filename checking here (check for ".deb")
- log.Println("bad filenae", filename)
- return nil
- }
- packageName := parts[0]
- letteredDir := log.Sprintf("%1.1s", filename)
- newfilename := filepath.Join("pool/main", letteredDir, packageName, filename)
- if newfilename == path {
- // the filename is correct
- return nil
- }
- destDir := filepath.Dir(newfilename)
- if err := os.MkdirAll(destDir, 0755); err != nil {
- log.Printf("%s move incoming oldname %s newname: %s\n", packageName, path, newfilename)
- log.Fatal("Failed to create destination directory: %v", err)
- }
- 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("OLD FILE", path)
- log.Info("NEW FILE", newfilename)
- log.Printf("files are the same %x %x\n", 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")
- }
- }
- os.Rename(path, newfilename)
- log.Printf("%s moved incoming oldname %s newname: %s\n", packageName, path, newfilename)
- incount += 1
- if incount > 100 {
- me.sh.GoodExit("file moved")
+ if !strings.HasPrefix(path, "pool/main") {
+ if config.Verbose() {
+ log.Info("already processed", path)
}
+ log.Info("TODO: fix this: ignoring files not in pool/main", path)
+ }
+ _, filename := filepath.Split(path)
+ parts := strings.Split(filename, "_")
+ if len(parts) != 3 {
+ // todo: add more filename checking here (check for ".deb")
+ log.Println("bad filenae", filename)
return nil
}
- if argv.Verbose {
- log.Info("already processed", path)
+ packageName := parts[0]
+ letteredDir := log.Sprintf("%1.1s", filename)
+ newfilename := filepath.Join("pool/main", letteredDir, packageName, filename)
+ if newfilename == path {
+ // the filename is correct
+ return nil
+ }
+ destDir := filepath.Dir(newfilename)
+ if err := os.MkdirAll(destDir, 0755); err != nil {
+ log.Printf("%s move incoming oldname %s newname: %s\n", packageName, 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("OLD FILE", path)
+ log.Info("NEW FILE", newfilename)
+ log.Printf("files are the same %x %x\n", 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. TODO: fix this to use --force to replace")
+ }
+ os.Rename(path, newfilename)
+ log.Printf("%s moved incoming oldname %s newname: %s\n", packageName, path, newfilename)
+ incount += 1
+ if incount > 100 {
+ me.sh.GoodExit("file moved")
}
+ return nil
// Get control info
// cmd := exec.Command("dpkg-deb", "-I", path)