From 3335fc81030eac1fae2078e29518b3028556c0e6 Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Thu, 9 Jan 2025 01:31:01 -0700 Subject: [PATCH 1/7] Update add.go --- core/commands/add.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index 8dcdd92171a..5f0f1f32481 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -24,6 +24,8 @@ import ( mh "github.com/multiformats/go-multihash" ) +var toFilesWrap bool + // ErrDepthLimitExceeded indicates that the max depth has been exceeded. var ErrDepthLimitExceeded = errors.New("depth limit exceeded") @@ -287,9 +289,9 @@ See 'dag export' and 'dag import' for more information. if onlyHash && toFilesSet { return fmt.Errorf("%s and %s options are not compatible", onlyHashOptionName, toFilesOptionName) } - +//1736410917 comment:line 290 if wrap && toFilesSet { - return fmt.Errorf("%s and %s options are not compatible", wrapOptionName, toFilesOptionName) +//1736410917 commented out return fmt.Errorf("%s and %s options are not compatible", wrapOptionName, toFilesOptionName) } hashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)] @@ -375,12 +377,13 @@ See 'dag export' and 'dag import' for more information. return } +//1736410917 comment:line 378 // creating MFS pointers when optional --to-files is set if toFilesSet { - if addit.Name() == "" { - errCh <- fmt.Errorf("%s: cannot add unnamed files to MFS", toFilesOptionName) - return - } +//1736410917 commented out if addit.Name() == "" { +//1736410917 commented out errCh <- fmt.Errorf("%s: cannot add unnamed files to MFS", toFilesOptionName) +//1736410917 commented out return +//1736410917 commented out } if toFilesStr == "" { toFilesStr = "/" @@ -405,7 +408,10 @@ See 'dag export' and 'dag import' for more information. return } // if MFS destination is a dir, append filename to the dir path - toFilesDst += gopath.Base(addit.Name()) +//1736410917 Was: +//1736410917 toFilesDst += gopath.Base(addit.Name()) + toFilesDst += gopath.Base(pathAdded.RootCid().String()) +//1736410917 Luckily, pathAdded.RootCid() is like the same thing as lastHash. You can see lastHash elsewhere in this file. } // error if we try to overwrite a preexisting file destination @@ -538,6 +544,7 @@ See 'dag export' and 'dag import' for more information. } lastFile := "" +//1736410917 comment:line 542: first instance of lastHash below lastHash := "" var totalProgress, prevFiles, lastBytes int64 From 8424b1f9dc508055a682bca624687888640d87c5 Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Thu, 9 Jan 2025 01:47:21 -0700 Subject: [PATCH 2/7] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 1018b0cd39b..db81f2d5315 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +PURPOSE OF THIS BRANCH/FORK AS OF +* https://github.com/ipfs/kubo/commit/3335fc81030eac1fae2078e29518b3028556c0e6 +* https://github.com/ProximaNova/kubo/commit/3335fc81030eac1fae2078e29518b3028556c0e6 + +IS TO DO THE FOLLOWING. Make ipfs add + --to-files + --wrap-with-directory work by adding the root CID of what was added to MFS. The is different from past official Kubo which did this: added a literal "." folder to MFS (bug). It's also different from current official Kubo: disallow add to be ran with to-files and wrap. Todo or ideas for this fork: make something like --to-files-cid which only adds root added CID to MFS, whether it's a file, folder, ran with wrap, ran without wrap. Also/or: add+to-files+wrap always defaults to adding the CID to MFS and not literal "." and not disabled; this is the best or easier idea to do. +


Kubo logo From 49d0c9d6344fba01ac69ff17895a011d85a55bcd Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Thu, 9 Jan 2025 21:54:11 -0700 Subject: [PATCH 3/7] Update add.go --- core/commands/add.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index 5f0f1f32481..758a2fe0a83 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -24,8 +24,6 @@ import ( mh "github.com/multiformats/go-multihash" ) -var toFilesWrap bool - // ErrDepthLimitExceeded indicates that the max depth has been exceeded. var ErrDepthLimitExceeded = errors.New("depth limit exceeded") @@ -290,8 +288,10 @@ See 'dag export' and 'dag import' for more information. return fmt.Errorf("%s and %s options are not compatible", onlyHashOptionName, toFilesOptionName) } //1736410917 comment:line 290 + var toFilesWrap bool = false if wrap && toFilesSet { //1736410917 commented out return fmt.Errorf("%s and %s options are not compatible", wrapOptionName, toFilesOptionName) + toFilesWrap = true } hashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)] @@ -409,8 +409,11 @@ See 'dag export' and 'dag import' for more information. } // if MFS destination is a dir, append filename to the dir path //1736410917 Was: -//1736410917 toFilesDst += gopath.Base(addit.Name()) - toFilesDst += gopath.Base(pathAdded.RootCid().String()) + if toFilesWrap { + toFilesDst += gopath.Base(pathAdded.RootCid().String()) + } else { + toFilesDst += gopath.Base(addit.Name()) + } //1736410917 Luckily, pathAdded.RootCid() is like the same thing as lastHash. You can see lastHash elsewhere in this file. } From 031400975ed1adccf8351b102206b58421d704d5 Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Thu, 9 Jan 2025 21:57:50 -0700 Subject: [PATCH 4/7] Update add.go --- core/commands/add.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index 758a2fe0a83..bd82b40eebb 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -287,10 +287,8 @@ See 'dag export' and 'dag import' for more information. if onlyHash && toFilesSet { return fmt.Errorf("%s and %s options are not compatible", onlyHashOptionName, toFilesOptionName) } -//1736410917 comment:line 290 var toFilesWrap bool = false if wrap && toFilesSet { -//1736410917 commented out return fmt.Errorf("%s and %s options are not compatible", wrapOptionName, toFilesOptionName) toFilesWrap = true } @@ -377,13 +375,12 @@ See 'dag export' and 'dag import' for more information. return } -//1736410917 comment:line 378 // creating MFS pointers when optional --to-files is set if toFilesSet { -//1736410917 commented out if addit.Name() == "" { -//1736410917 commented out errCh <- fmt.Errorf("%s: cannot add unnamed files to MFS", toFilesOptionName) -//1736410917 commented out return -//1736410917 commented out } +// if addit.Name() == "" { +// errCh <- fmt.Errorf("%s: cannot add unnamed files to MFS", toFilesOptionName) +// return +// } if toFilesStr == "" { toFilesStr = "/" @@ -408,13 +405,12 @@ See 'dag export' and 'dag import' for more information. return } // if MFS destination is a dir, append filename to the dir path -//1736410917 Was: if toFilesWrap { + // pathAdded.RootCid() is like the same thing as lastHash. See lastHash below in this file. toFilesDst += gopath.Base(pathAdded.RootCid().String()) } else { toFilesDst += gopath.Base(addit.Name()) } -//1736410917 Luckily, pathAdded.RootCid() is like the same thing as lastHash. You can see lastHash elsewhere in this file. } // error if we try to overwrite a preexisting file destination @@ -547,7 +543,6 @@ See 'dag export' and 'dag import' for more information. } lastFile := "" -//1736410917 comment:line 542: first instance of lastHash below lastHash := "" var totalProgress, prevFiles, lastBytes int64 From e3e59729f94d65d3fb060738b52eac7e42948950 Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Thu, 9 Jan 2025 22:04:13 -0700 Subject: [PATCH 5/7] Update README.md --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index db81f2d5315..1018b0cd39b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,3 @@ -PURPOSE OF THIS BRANCH/FORK AS OF -* https://github.com/ipfs/kubo/commit/3335fc81030eac1fae2078e29518b3028556c0e6 -* https://github.com/ProximaNova/kubo/commit/3335fc81030eac1fae2078e29518b3028556c0e6 - -IS TO DO THE FOLLOWING. Make ipfs add + --to-files + --wrap-with-directory work by adding the root CID of what was added to MFS. The is different from past official Kubo which did this: added a literal "." folder to MFS (bug). It's also different from current official Kubo: disallow add to be ran with to-files and wrap. Todo or ideas for this fork: make something like --to-files-cid which only adds root added CID to MFS, whether it's a file, folder, ran with wrap, ran without wrap. Also/or: add+to-files+wrap always defaults to adding the CID to MFS and not literal "." and not disabled; this is the best or easier idea to do. -


Kubo logo From 7ec0c8cb3ed9090f76cf513f9bb19637cd5655b2 Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Thu, 9 Jan 2025 22:07:12 -0700 Subject: [PATCH 6/7] Update v0.33.md --- docs/changelogs/v0.33.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelogs/v0.33.md b/docs/changelogs/v0.33.md index bf012f4e91c..af5c2ce0291 100644 --- a/docs/changelogs/v0.33.md +++ b/docs/changelogs/v0.33.md @@ -57,9 +57,9 @@ New repositories initialized with `flatfs` in `Datastore.Spec` will have `sync` The old default was overly conservative and caused performance issues in big repositories that did a lot of writes. There is usually no need to flush on every block write to disk before continuing. Setting this to false is safe as kubo will automatically flush writes to disk before and after performing critical operations like pinning. However, we still provide users with ability to set this to true to be extra-safe (at the cost of a slowdown when adding files in bulk). -#### `ipfs add --to-files` no longer works with `--wrap` +#### `ipfs add --to-files` works better with `--wrap` -Onboarding files and directories with `ipfs add --to-files` now requires non-empty names. due to this, The `--to-files` and `--wrap` options are now mutually exclusive ([#10612](https://github.com/ipfs/kubo/issues/10612)). +Onboarding files and directories with `ipfs add --to-files` now requires non-empty names. due to this, The `--to-files` and `--wrap` now adds the final/wrapped CID to MFS instead of a literal "." ([#10612](https://github.com/ipfs/kubo/issues/10612)). #### New options for faster writes: `WriteThrough`, `BlockKeyCacheSize`, `BatchMaxNodes`, `BatchMaxSize` From a2109cb656846f4d92a59db9a1016324cdc81d13 Mon Sep 17 00:00:00 2001 From: guillaumemichel Date: Tue, 21 Jan 2025 10:51:30 +0100 Subject: [PATCH 7/7] fix: cleanup --- core/commands/add.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index bd82b40eebb..c815a2e0c4b 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -287,10 +287,6 @@ See 'dag export' and 'dag import' for more information. if onlyHash && toFilesSet { return fmt.Errorf("%s and %s options are not compatible", onlyHashOptionName, toFilesOptionName) } - var toFilesWrap bool = false - if wrap && toFilesSet { - toFilesWrap = true - } hashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)] if !ok { @@ -377,11 +373,6 @@ See 'dag export' and 'dag import' for more information. // creating MFS pointers when optional --to-files is set if toFilesSet { -// if addit.Name() == "" { -// errCh <- fmt.Errorf("%s: cannot add unnamed files to MFS", toFilesOptionName) -// return -// } - if toFilesStr == "" { toFilesStr = "/" } @@ -405,7 +396,7 @@ See 'dag export' and 'dag import' for more information. return } // if MFS destination is a dir, append filename to the dir path - if toFilesWrap { + if wrap && toFilesSet { // pathAdded.RootCid() is like the same thing as lastHash. See lastHash below in this file. toFilesDst += gopath.Base(pathAdded.RootCid().String()) } else {