Last active
November 13, 2020 21:00
-
-
Save MSevey/4b7fa436124765e2b80f1851d3a08e1b to your computer and use it in GitHub Desktop.
Used with the skynet-portal-rename to clean up all the renaming. Add to `modules/renter/renter.go` ~line 1053
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SEVEY: Handle directory rename | |
if build.Release != "testing" { | |
f, err := os.Open(filepath.Join(r.persistDir, "dirpaths")) | |
if err != nil { | |
return nil, errors.AddContext(err, "unable to open dirpaths file") | |
} | |
urp := r.newUniqueRefreshPaths() | |
r.log.Println("SEVEY: Reading dirs") | |
totalDirs := 0 | |
scanner := bufio.NewScanner(f) | |
profile.ToggleTimer("StartUp Bubble Loop") | |
str := fmt.Sprint("250k Directories", time.Now()) | |
profile.ToggleTimer(str) | |
for scanner.Scan() { | |
totalDirs++ | |
siaPath, err := modules.NewSiaPath(scanner.Text()) | |
if err != nil { | |
return nil, err | |
} | |
err = r.staticFileSystem.NewSiaDir(siaPath, modules.DefaultDirPerm) | |
if err != nil && !errors.Contains(err, filesystem.ErrExists) { | |
return nil, err | |
} | |
err = urp.callAdd(siaPath) | |
if err != nil { | |
return nil, err | |
} | |
if totalDirs%250000 == 0 { | |
profile.ToggleTimer(str) | |
_ = urp.callRefreshAllBlocking() | |
urp = r.newUniqueRefreshPaths() | |
r.log.Println("SEVEY:", totalDirs, "handled") | |
str = fmt.Sprint("250k Directories", time.Now()) | |
profile.ToggleTimer(str) | |
} | |
} | |
r.log.Println("SEVEY: Calling bubble on dirs") | |
err = urp.callRefreshAllBlocking() | |
if err != nil { | |
return nil, err | |
} | |
profile.ToggleTimer(str) | |
profile.ToggleTimer("StartUp Bubble Loop") | |
r.log.Println("SEVEY: All dirs created and bubbles called") | |
r.log.Println(profile.PrintTimes()) | |
err = errors.Compose(f.Close(), scanner.Err()) | |
if err != nil { | |
return nil, err | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment