mirror of
https://github.com/restic/restic.git
synced 2026-06-22 00:24:18 +00:00
Fix 567 (#570)
* Patch for https://github.com/restic/restic/issues/567 Backup also files on windows with longer pathnames than 255 chars (e.g. from node). as fd0 says "So, as far as I can see, we need to have custom methods for all functions that accept a path, so that on Windows we can substitute the normal (possibly relative) path used within restic by an (absolute) UNC path, and only then call the underlying functions like os.Stat(), os.Lstat(), os.Open() and so on. I've already thought about adding a generic abstraction for the file system (so we can mock this easier in tests), and this looks like a good opportunity to build it." * fixed building tests * Restructured patches Add Wrapper for filepath.Walk * using \\?\ requires absolute pathes to be used. Now all tests run * used gofmt on the code * Restructured Code. No patches dir, integrate the file functions into restic/fs/ There is still an issue, because restic.fs.Open has a different api the os.Open, which returns the result of OpenFile, but takes only a string * Changed the last os.Open() calls to fs.Open() after extending the File interface * fixed name-clash of restic.fs and fuse.fs detected by travis * fixed fmt with gofmt * c&p failure: removed fixpath() call. * missing include * fixed includes in linux variant * Fix for Linux. Fd() is required on File interface * done gofmt
This commit is contained in:
committed by
Alexander Neumann
parent
4b8b625b90
commit
b108966b12
@@ -12,6 +12,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"restic/fs"
|
||||
)
|
||||
|
||||
// Context contains repository meta-data.
|
||||
@@ -134,7 +136,7 @@ func GetBlob(c *Context) http.HandlerFunc {
|
||||
dir := vars[1]
|
||||
name := vars[2]
|
||||
path := filepath.Join(c.path, dir, name)
|
||||
file, err := os.Open(path)
|
||||
file, err := fs.Open(path)
|
||||
if err != nil {
|
||||
http.Error(w, "404 not found", 404)
|
||||
return
|
||||
@@ -152,7 +154,7 @@ func SaveBlob(c *Context) http.HandlerFunc {
|
||||
name := vars[2]
|
||||
path := filepath.Join(c.path, dir, name)
|
||||
tmp := path + "_tmp"
|
||||
tf, err := os.OpenFile(tmp, os.O_CREATE|os.O_WRONLY, 0600)
|
||||
tf, err := fs.OpenFile(tmp, os.O_CREATE|os.O_WRONLY, 0600)
|
||||
if err != nil {
|
||||
http.Error(w, "500 internal server error", 500)
|
||||
return
|
||||
|
||||
@@ -32,7 +32,8 @@ import (
|
||||
"encoding/csv"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"restic/fs"
|
||||
)
|
||||
|
||||
// lookup passwords in a htpasswd file
|
||||
@@ -47,7 +48,7 @@ type HtpasswdFile struct {
|
||||
// file and returns them. If an error is encountered, it is returned, together
|
||||
// with a nil-Pointer for the HtpasswdFile.
|
||||
func NewHtpasswdFromFile(path string) (*HtpasswdFile, error) {
|
||||
r, err := os.Open(path)
|
||||
r, err := fs.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"restic/backend"
|
||||
"restic/debug"
|
||||
"restic/filter"
|
||||
"restic/fs"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -221,7 +222,7 @@ func (cmd CmdBackup) newArchiveStdinProgress() *restic.Progress {
|
||||
// items exist at all.
|
||||
func filterExisting(items []string) (result []string, err error) {
|
||||
for _, item := range items {
|
||||
_, err := os.Lstat(item)
|
||||
_, err := fs.Lstat(item)
|
||||
if err != nil && os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
@@ -334,7 +335,7 @@ func (cmd CmdBackup) Execute(args []string) error {
|
||||
|
||||
// add patterns from file
|
||||
if cmd.ExcludeFile != "" {
|
||||
file, err := os.Open(cmd.ExcludeFile)
|
||||
file, err := fs.Open(cmd.ExcludeFile)
|
||||
if err != nil {
|
||||
cmd.global.Warnf("error reading exclude patterns: %v", err)
|
||||
return nil
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
resticfs "restic/fs"
|
||||
"restic/fuse"
|
||||
|
||||
systemFuse "bazil.org/fuse"
|
||||
@@ -55,9 +56,9 @@ func (cmd CmdMount) Execute(args []string) error {
|
||||
}
|
||||
|
||||
mountpoint := args[0]
|
||||
if _, err := os.Stat(mountpoint); os.IsNotExist(err) {
|
||||
if _, err := resticfs.Stat(mountpoint); os.IsNotExist(err) {
|
||||
cmd.global.Verbosef("Mountpoint %s doesn't exist, creating it\n", mountpoint)
|
||||
err = os.Mkdir(mountpoint, os.ModeDir|0700)
|
||||
err = resticfs.Mkdir(mountpoint, os.ModeDir|0700)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user