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

feat(repo): FSRepo #546

Merged
merged 32 commits into from
Jan 13, 2015
Merged

feat(repo): FSRepo #546

merged 32 commits into from
Jan 13, 2015

Conversation

btc
Copy link
Contributor

@btc btc commented Jan 13, 2015

@jbenet @whyrusleeping

This introduces the repo.Interface as described in #376.

First step, bring the config under management (in-progress). Then, bring the datastore under management. Finally, make use the repo.Interface in the core.IpfsNode.

@btc btc added the status/in-progress In progress label Jan 13, 2015
@btc btc force-pushed the feat/repo-fsrepo branch 2 times, most recently from 211254a to ca4143d Compare January 13, 2015 02:55
}
if err := r.Close(); err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i'm reading this right, ipfs init -f would not blow out the datastore, correct?

I wonder which is easier on the user:

ipfs init -f   # re-inits config
rm -rf ~/.go-ipfs/datastore

ipfs init -f   # re-inits config, blows out everything
ipfs init --config  # only reinits config

# no ipfs init -f
ipfs init --config  # only reinits config
ipfs init --datastore  # only reinits datastore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ipfs init -f   # re-inits config
# "I used init -f. Why does it still say this key exists?"

# oh wait the datastore is still there. oops.
rm -rf ~/.go-ipfs/datastore


ipfs init -f # seems like the expected behavior
ipfs init --config  # SGTM

# no ipfs init -f (i think init -f is nice to have as the default)

# both would probably be fine to provide
ipfs init --config
ipfs init --datastore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbenet that was a mistake. I'm thinking init -f should probably remove the datastore. Let me know what you think.

@jbenet
Copy link
Member

jbenet commented Jan 13, 2015

I'm in love with this PR. so much complexity reduction. ❤️ ❤️ ❤️ ❤️ ❤️

@jbenet
Copy link
Member

jbenet commented Jan 13, 2015

LGTM

@btc
Copy link
Contributor Author

btc commented Jan 13, 2015

@jbenet Addressed the init -f behavior. Forcing init will remove the datastore and anything else under the directory.

Since last review, I added a packageLock to ensure that directories cannot be wiped out while an FSRepo is Open. FSRepos at independent paths can be removed independently.

I'm satisfied with scope of this PR. Going to freeze at this point.

Still TODO...

  • add repo lock (formerly daemon lock)
  • bring datastore under management

If this passes tests and still LGTU, ready for merge.


if u.FileExists(configFilename) && !force {
if fsrepo.IsInitialized(repoRoot) && !force {
return nil, errCannotInitConfigExists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change error name to errAlreadyInited or errRepoExists? (nbd)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbenet
Copy link
Member

jbenet commented Jan 13, 2015

Comments:

Otherwise, LGTM, RTM.

This is a great PR, thanks, and can't wait to have it merged.

@btc
Copy link
Contributor Author

btc commented Jan 13, 2015

  • renamed repo.Repo
  • using TempDir for config
  • punting on moving the filename constants in this PR. Needs to be moved eventually, but we can afford the debt for now.

Brian Tiger Chow added 21 commits January 13, 2015 03:09
@jbenet this removes everything under the path
The pkg.Interface style is modeled after heap.Interface. Generally, I
find it helpful for interfaces that have many implementations. It
provides clear distinction between the generic interface and the |n|
implementations that implement it (which may be interface types
themselves).

For clients who cannot keep the repo name, one can imagine that the most
likely rename is `ipfsrepo`. In that case, `ipfsrepo.Interface` remains
meaningful.

This is low-pri so it doesn't matter than much. But for the record, the
repo.Interface feels appropriate in this use-case.
btc pushed a commit that referenced this pull request Jan 13, 2015
@btc btc merged commit e5bd30b into master Jan 13, 2015
@btc btc removed the status/in-progress In progress label Jan 13, 2015
@btc btc deleted the feat/repo-fsrepo branch January 13, 2015 11:37
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.

2 participants