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

PieceIO improvements #12

Merged
merged 6 commits into from
Dec 19, 2019
Merged

PieceIO improvements #12

merged 6 commits into from
Dec 19, 2019

Conversation

ergastic
Copy link
Contributor

Changes in this PR:

  • Improved test coverage for PieceIO.
  • Changed PieceIO to use FileStore.
  • Added CreateTemp method to FileStore.
  • Enabled FileStore tests.

@hannahhoward
Copy link
Collaborator

hannahhoward commented Dec 17, 2019

George can you rebase to resolve merge issues?

Copy link
Contributor

@ingar ingar left a 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 👍

filestore/filestore.go Outdated Show resolved Hide resolved
filestore/filestore.go Outdated Show resolved Hide resolved
ergastic added 5 commits December 18, 2019 17:54
Copy link
Contributor

@ingar ingar left a 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.

}

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))
Copy link
Contributor

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...

Suggested change
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)
}

Comment on lines 64 to 68
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)
}
}
Copy link
Contributor

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.

@ergastic ergastic merged commit d9fb621 into master Dec 19, 2019
@ergastic ergastic deleted the feat/pieceio branch December 19, 2019 20:06
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

Successfully merging this pull request may close these issues.

3 participants