fix: Use offset to prevent re-indexing encrypted headers
This commit is contained in:
@@ -2,11 +2,13 @@ package operations
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pojntfx/stfs/internal/compression"
|
||||
"github.com/pojntfx/stfs/internal/converters"
|
||||
@@ -22,6 +24,10 @@ import (
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
)
|
||||
|
||||
var (
|
||||
errSocketsNotSupported = errors.New("archive/tar: sockets not supported")
|
||||
)
|
||||
|
||||
func Archive(
|
||||
state config.StateConfig,
|
||||
pipes config.PipeConfig,
|
||||
@@ -107,6 +113,11 @@ func Archive(
|
||||
|
||||
hdr, err := tar.FileInfoHeader(info, link)
|
||||
if err != nil {
|
||||
// Skip sockets
|
||||
if strings.Contains(err.Error(), errSocketsNotSupported.Error()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -220,6 +231,8 @@ func Archive(
|
||||
return err
|
||||
}
|
||||
|
||||
dirty = true
|
||||
|
||||
if !info.Mode().IsRegular() {
|
||||
return nil
|
||||
}
|
||||
@@ -273,8 +286,6 @@ func Archive(
|
||||
return err
|
||||
}
|
||||
|
||||
dirty = true
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -106,18 +106,14 @@ func Delete(
|
||||
int(lastIndexedRecord),
|
||||
int(lastIndexedBlock),
|
||||
false,
|
||||
1, // Ignore the first header, which is the last header which we already indexed
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if len(hdrs) <= i-1 {
|
||||
if len(hdrs) <= i {
|
||||
return config.ErrTarHeaderMissing
|
||||
}
|
||||
|
||||
*hdr = *hdrs[i-1]
|
||||
*hdr = *hdrs[i]
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -110,18 +110,14 @@ func Move(
|
||||
int(lastIndexedRecord),
|
||||
int(lastIndexedBlock),
|
||||
false,
|
||||
1, // Ignore the first header, which is the last header which we already indexed
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if len(hdrs) <= i-1 {
|
||||
if len(hdrs) <= i {
|
||||
return config.ErrTarHeaderMissing
|
||||
}
|
||||
|
||||
*hdr = *hdrs[i-1]
|
||||
*hdr = *hdrs[i]
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user