prune lookaside files that change in the same stream

This commit is contained in:
Mustafa Gezen 2021-01-01 16:55:21 +01:00
parent 059cb525a7
commit 9de0f812f5
2 changed files with 17 additions and 7 deletions

View File

@ -175,7 +175,7 @@ func (g *GitMode) WriteSource(md *modeData) {
}
md.sourcesToIgnore = append(md.sourcesToIgnore, &ignoredSource{
name: filepath.Base(path),
name: path,
hashFunction: hasher,
})
@ -189,9 +189,12 @@ func (g *GitMode) WriteSource(md *modeData) {
func (g *GitMode) PostProcess(md *modeData) {
for _, source := range md.sourcesToIgnore {
err := md.worktree.Filesystem.Remove(filepath.Join("SOURCES", source.name))
if err != nil {
log.Fatalf("could not remove dist-git file: %v", err)
_, err := md.worktree.Filesystem.Stat(source.name)
if err == nil {
err := md.worktree.Filesystem.Remove(source.name)
if err != nil {
log.Fatalf("could not remove dist-git file: %v", err)
}
}
}

View File

@ -43,6 +43,7 @@ type ProcessData struct {
type ignoredSource struct {
name string
hashFunction hash.Hash
expired bool
}
type modeData struct {
@ -112,7 +113,9 @@ func ProcessRPM(pd *ProcessData) {
md.repo = &sourceRepo
md.worktree = &sourceWorktree
md.tagBranch = branch
md.sourcesToIgnore = []*ignoredSource{}
for _, source := range md.sourcesToIgnore {
source.expired = true
}
rpmFile := md.rpmFile
// create new repo for final dist
@ -217,7 +220,11 @@ func ProcessRPM(pd *ProcessData) {
log.Fatalf("could not create metadata file: %v", err)
}
for _, source := range md.sourcesToIgnore {
sourcePath := "SOURCES/" + source.name
if source.expired {
continue
}
sourcePath := source.name
sourceFile, err := w.Filesystem.Open(sourcePath)
if err != nil {
log.Fatalf("could not open ignored source file %s: %v", sourcePath, err)
@ -239,7 +246,7 @@ func ProcessRPM(pd *ProcessData) {
log.Fatalf("could not write to metadata file: %v", err)
}
path := fmt.Sprintf("%s/%s", rpmFile.Name(), checksum)
path := fmt.Sprintf("%s", checksum)
if strContains(alreadyUploadedBlobs, path) {
continue
}