archive: fix socket files aborting backups
This commit is contained in:
parent
73570c7144
commit
29b2d6826a
|
@ -3,6 +3,7 @@ package filesystem
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -13,8 +14,9 @@ import (
|
||||||
"github.com/juju/ratelimit"
|
"github.com/juju/ratelimit"
|
||||||
"github.com/karrick/godirwalk"
|
"github.com/karrick/godirwalk"
|
||||||
"github.com/klauspost/pgzip"
|
"github.com/klauspost/pgzip"
|
||||||
"github.com/pterodactyl/wings/config"
|
|
||||||
"github.com/sabhiram/go-gitignore"
|
"github.com/sabhiram/go-gitignore"
|
||||||
|
|
||||||
|
"github.com/pterodactyl/wings/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
const memory = 4 * 1024
|
const memory = 4 * 1024
|
||||||
|
@ -156,9 +158,15 @@ func (a *Archive) addToArchive(p string, rp string, w *tar.Writer) error {
|
||||||
return errors.WrapIff(err, "failed executing os.Lstat on '%s'", rp)
|
return errors.WrapIff(err, "failed executing os.Lstat on '%s'", rp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip socket files as they are unsupported by archive/tar.
|
||||||
|
// Error will come from tar#FileInfoHeader: "archive/tar: sockets not supported"
|
||||||
|
if s.Mode()&fs.ModeSocket != 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve the symlink target if the file is a symlink.
|
// Resolve the symlink target if the file is a symlink.
|
||||||
var target string
|
var target string
|
||||||
if s.Mode()&os.ModeSymlink != 0 {
|
if s.Mode()&fs.ModeSymlink != 0 {
|
||||||
// Read the target of the symlink. If there are any errors we will dump them out to
|
// Read the target of the symlink. If there are any errors we will dump them out to
|
||||||
// the logs, but we're not going to stop the backup. There are far too many cases of
|
// the logs, but we're not going to stop the backup. There are far too many cases of
|
||||||
// symlinks causing all sorts of unnecessary pain in this process. Sucks to suck if
|
// symlinks causing all sorts of unnecessary pain in this process. Sucks to suck if
|
||||||
|
@ -180,7 +188,7 @@ func (a *Archive) addToArchive(p string, rp string, w *tar.Writer) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix the header name if the file is not a symlink.
|
// Fix the header name if the file is not a symlink.
|
||||||
if s.Mode()&os.ModeSymlink == 0 {
|
if s.Mode()&fs.ModeSymlink == 0 {
|
||||||
header.Name = rp
|
header.Name = rp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user