Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs/kubo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d4037f5f889b^
Choose a base ref
...
head repository: ipfs/kubo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8a4c15dde29d
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 29, 2015

  1. ipnsfs: remove "Publishing!" println

    use `log.Info(...)` and `defer log.Event(...).Done()` instead
    
    License: MIT
    Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
    jbenet committed Jul 29, 2015
    Copy the full SHA
    d4037f5 View commit details
  2. ipnsfs: remove context.TODO(), wire to FS context

    License: MIT
    Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
    jbenet committed Jul 29, 2015
    Copy the full SHA
    8a4c15d View commit details
Showing with 14 additions and 5 deletions.
  1. +14 −5 ipnsfs/system.go
19 changes: 14 additions & 5 deletions ipnsfs/system.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ package ipnsfs

import (
"errors"
"fmt"
"os"
"sync"
"time"
@@ -35,6 +34,8 @@ var ErrIsDirectory = errors.New("error: is a directory")

// Filesystem is the writeable fuse filesystem structure
type Filesystem struct {
ctx context.Context

dserv dag.DAGService

nsys namesys.NameSystem
@@ -50,6 +51,7 @@ type Filesystem struct {
func NewFilesystem(ctx context.Context, ds dag.DAGService, nsys namesys.NameSystem, pins pin.Pinner, keys ...ci.PrivKey) (*Filesystem, error) {
roots := make(map[string]*KeyRoot)
fs := &Filesystem{
ctx: ctx,
roots: roots,
nsys: nsys,
dserv: ds,
@@ -78,7 +80,7 @@ func (fs *Filesystem) Close() error {
wg.Add(1)
go func(r *KeyRoot) {
defer wg.Done()
err := r.Publish(context.TODO())
err := r.Publish(fs.ctx)
if err != nil {
log.Info(err)
return
@@ -119,7 +121,8 @@ type FSNode interface {

// KeyRoot represents the root of a filesystem tree pointed to by a given keypair
type KeyRoot struct {
key ci.PrivKey
key ci.PrivKey
name string

// node is the merkledag node pointed to by this keypair
node *dag.Node
@@ -146,6 +149,7 @@ func (fs *Filesystem) newKeyRoot(parent context.Context, k ci.PrivKey) (*KeyRoot
root := new(KeyRoot)
root.key = k
root.fs = fs
root.name = name

ctx, cancel := context.WithCancel(parent)
defer cancel()
@@ -230,8 +234,13 @@ func (kr *KeyRoot) Publish(ctx context.Context) error {
// otherwise we are holding the lock through a costly
// network operation

fmt.Println("Publishing!")
return kr.fs.nsys.Publish(ctx, kr.key, path.FromKey(k))
kp := path.FromKey(k)

ev := &eventlog.Metadata{"name": kr.name, "key": kp}
defer log.EventBegin(ctx, "ipnsfsPublishing", ev).Done()
log.Info("ipnsfs publishing %s -> %s", kr.name, kp)

return kr.fs.nsys.Publish(ctx, kr.key, kp)
}

// Republisher manages when to publish the ipns entry associated with a given key