Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fatal] Filepaths on windows are not resolved absolutely - files with dot at the end cause problems. #2831

Closed
monoclex opened this issue Jul 11, 2020 · 1 comment

Comments

@monoclex
Copy link

monoclex commented Jul 11, 2020

Output of restic version

restic 0.9.6 compiled with go1.13.4 on windows/amd64

How did you run restic exactly?

In powershell, .\restic -r F:\Backup backup C:\. This directly followed installation, and I haven't done any modification to any configuration. I was just backing up my files when I ran into this rabbit hole :'D

What backend/server/service did you use to store the repository?

Filesystem

Expected behavior

No error - it should backup the directory with ease.

Actual behavior

Restic fails on a "fatal" and fails at backing up.

Fatal: unable to save snapshot: node "a" is already present

Steps to reproduce the behavior

Open up powershell and run the following:

mkdir C:\repro\source
cd C:\repro\source
mkdir "\\?\C:\repro\source\a"
mkdir "\\?\C:\repro\source\a."
restic init -r C:\repro\repo
restic backup -r C:\repro\repo C:\repro\source

enter password for repository:
repository 3682bc9a opened successfully, password is correct
Fatal: unable to save snapshot: node "a" is already present

Do you have any idea what may have caused this?

File path expansion.

Do you have an idea how to solve the issue?

Ensure that the \\?\ prefix is being used at all times when dealing with filepaths on Windows. As per the documentation,

Because it turns off automatic expansion of the path string, the "\\?\" prefix also allows the use of ".." and "." in the path names, which can be useful if you are attempting to perform operations on a file with these otherwise reserved relative path specifiers as part of the fully qualified path.

A proof of concept of the above concept working can be shown in this example (Note: I am not a go programmer):

package main

import (
    "os"
)

func check(e error) {
    if e != nil {
        panic(e)
    }
}

func main() {
	err := os.Mkdir("\\\\?\\C:\\repro\\test.", 0755)
	check(err)
}

Did restic help you today? Did it make you happy in any way?

:P

@MichaelEischer
Copy link
Member

Closing this as duplicate of #2745 . Restic already prepends \\?\ to paths, the problem is that restic currently uses a windows function (too often) that is canonicalizing paths too eagerly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants