-
Notifications
You must be signed in to change notification settings - Fork 58
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
PieceIO improvements #12
Conversation
George can you rebase to resolve merge issues? |
11898cf
to
1c739ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the Delete()
trying to delete the raw path first, and afterwards trying the filestore path is risky enough that we should change it to only act on files in the filestore.. Other than that 👍
2. Changed PieceIO to use FileStore. 3. Added CreateTemp method to FileStore. 4. Enabled FileStore tests.
…ple effects of that.)
e80a1e9
to
839d5c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for the changes.
filestore/file.go
Outdated
} | ||
|
||
func (f fd) Size() int64 { | ||
info, err := os.Stat(f.filename) | ||
info, err := os.Stat(fmt.Sprintf("%s%c%s", f.basepath, filepath.Separator, f.filename)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we are creating a full path a few times a few different ways; we could do...
info, err := os.Stat(fmt.Sprintf("%s%c%s", f.basepath, filepath.Separator, f.filename)) | |
info, err := os.Stat(f.absPath()) |
if we had a function:
func (f fd) absPath() string {
return path.Join(f.basepath, f.filename)
}
filestore/filestore.go
Outdated
for idx := range fs.base { | ||
if p[idx] != fs.base[idx] { | ||
return fmt.Errorf("invalid base path for '%s' (expecting '%s')", string(p), fs.base) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a strings.HasPrefix
that can do this.
Changes in this PR: