fix: Enable computation of last known record and block based on lastknownrecord and lastknownblock even if last changes are updates

This commit is contained in:
Felicitas Pojtinger
2021-12-06 23:55:31 +01:00
parent ee5d3c72d9
commit 943d92d052
17 changed files with 203 additions and 175 deletions

View File

@@ -174,11 +174,16 @@ var archiveCmd = &cobra.Command{
viper.GetBool(overwriteFlag),
func(hdr *tar.Header, i int) error {
if len(hdrs) <= i {
// Ignore the first header, which is the last header which we already indexed
if i == 0 {
return nil
}
if len(hdrs) <= i-1 {
return errMissingTarHeader
}
*hdr = *hdrs[i]
*hdr = *hdrs[i-1]
return nil
},
@@ -372,7 +377,7 @@ func archive(
first = false
}
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, hdr)); err != nil {
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, -1, -1, hdr)); err != nil {
return err
}

View File

@@ -153,7 +153,7 @@ func delete(
dirty = true
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, hdr)); err != nil {
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, -1, -1, hdr)); err != nil {
return err
}
}

View File

@@ -150,7 +150,7 @@ func move(
dirty = true
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, hdr)); err != nil {
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, -1, -1, hdr)); err != nil {
return err
}
}

View File

@@ -112,7 +112,7 @@ var restoreCmd = &cobra.Command{
return err
}
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(dbhdr.Record, dbhdr.Block, hdr)); err != nil {
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(dbhdr.Record, dbhdr.Lastknownrecord, dbhdr.Block, dbhdr.Lastknownblock, hdr)); err != nil {
return err
}

View File

@@ -120,6 +120,7 @@ var updateCmd = &cobra.Command{
false,
func(hdr *tar.Header, i int) error {
// Ignore the first header, which is the last header which we already indexed
if i == 0 {
return nil
}
@@ -279,7 +280,7 @@ func update(
if replacesContent {
hdr.PAXRecords[pax.STFSRecordReplacesContent] = pax.STFSRecordReplacesContentTrue
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, hdr)); err != nil {
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, -1, -1, hdr)); err != nil {
return err
}
@@ -353,7 +354,7 @@ func update(
} else {
hdr.Size = 0 // Don't try to seek after the record
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, hdr)); err != nil {
if err := formatting.PrintCSV(formatting.GetTARHeaderAsCSV(-1, -1, -1, -1, hdr)); err != nil {
return err
}