mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-07 05:42:42 +00:00
Allow using files from the pool while importing source packages
Sometimes source packages reference files already present in the pool. Allow for those file to be omitted when importing packages either via `repo add` or `repo include`. If file is missing, aptly would make an attempt to look up file in the package pool (by checksum) and use it. Fixes: #278
This commit is contained in:
+23
-3
@@ -147,14 +147,34 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
||||
// go over all the other files
|
||||
for i := range files {
|
||||
sourceFile := filepath.Join(filepath.Dir(file), filepath.Base(files[i].Filename))
|
||||
files[i].PoolPath, err = pool.Import(sourceFile, files[i].Filename, &files[i].Checksums, false, checksumStorage)
|
||||
|
||||
_, err = os.Stat(sourceFile)
|
||||
if err == nil {
|
||||
files[i].PoolPath, err = pool.Import(sourceFile, files[i].Filename, &files[i].Checksums, false, checksumStorage)
|
||||
if err == nil {
|
||||
candidateProcessedFiles = append(candidateProcessedFiles, sourceFile)
|
||||
}
|
||||
} else if os.IsNotExist(err) {
|
||||
// if file is not present, try to find it in the pool
|
||||
var (
|
||||
err2 error
|
||||
found bool
|
||||
)
|
||||
|
||||
files[i].PoolPath, found, err2 = pool.Verify("", files[i].Filename, &files[i].Checksums, checksumStorage)
|
||||
if err2 != nil {
|
||||
err = err2
|
||||
} else if found {
|
||||
// clear error, file is already in the package pool
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
reporter.Warning("Unable to import file %s into pool: %s", sourceFile, err)
|
||||
failedFiles = append(failedFiles, file)
|
||||
break
|
||||
}
|
||||
|
||||
candidateProcessedFiles = append(candidateProcessedFiles, sourceFile)
|
||||
}
|
||||
if err != nil {
|
||||
// some files haven't been imported
|
||||
|
||||
Reference in New Issue
Block a user