mirror of
https://github.com/caddyserver/caddy.git
synced 2025-03-23 05:49:27 +01:00
Fix ACME asset migration when renaming folders
This commit is contained in:
parent
df018ea64a
commit
38c2463416
1 changed files with 18 additions and 11 deletions
|
@ -188,18 +188,25 @@ func moveStorage() {
|
||||||
log.Fatalf("[ERROR] Unable to migrate certificate storage: %v\n\nPlease follow instructions at:\nhttps://github.com/mholt/caddy/issues/902#issuecomment-228876011", err)
|
log.Fatalf("[ERROR] Unable to migrate certificate storage: %v\n\nPlease follow instructions at:\nhttps://github.com/mholt/caddy/issues/902#issuecomment-228876011", err)
|
||||||
}
|
}
|
||||||
// convert mixed case folder and file names to lowercase
|
// convert mixed case folder and file names to lowercase
|
||||||
filepath.Walk(string(newPath), func(path string, info os.FileInfo, err error) error {
|
var done bool // walking is recursive and preloads the file names, so we must restart walk after a change until no changes
|
||||||
// must be careful to only lowercase the base of the path, not the whole thing!!
|
for !done {
|
||||||
base := filepath.Base(path)
|
done = true
|
||||||
if lowerBase := strings.ToLower(base); base != lowerBase {
|
filepath.Walk(string(newPath), func(path string, info os.FileInfo, err error) error {
|
||||||
lowerPath := filepath.Join(filepath.Dir(path), lowerBase)
|
// must be careful to only lowercase the base of the path, not the whole thing!!
|
||||||
err = os.Rename(path, lowerPath)
|
base := filepath.Base(path)
|
||||||
if err != nil {
|
if lowerBase := strings.ToLower(base); base != lowerBase {
|
||||||
log.Fatalf("[ERROR] Unable to lower-case: %v\n\nPlease follow instructions at:\nhttps://github.com/mholt/caddy/issues/902#issuecomment-228876011", err)
|
lowerPath := filepath.Join(filepath.Dir(path), lowerBase)
|
||||||
|
err = os.Rename(path, lowerPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("[ERROR] Unable to lower-case: %v\n\nPlease follow instructions at:\nhttps://github.com/mholt/caddy/issues/902#issuecomment-228876011", err)
|
||||||
|
}
|
||||||
|
// terminate traversal and restart since Walk needs the updated file list with new file names
|
||||||
|
done = false
|
||||||
|
return errors.New("start over")
|
||||||
}
|
}
|
||||||
}
|
return nil
|
||||||
return nil
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setVersion figures out the version information
|
// setVersion figures out the version information
|
||||||
|
|
Loading…
Reference in a new issue