-
Notifications
You must be signed in to change notification settings - Fork 1.2k
determine the files to be different sizes #3209
Comments
I'm not sure if this is because share.ipfs.io is out of date or not. However, I did try adding the same files from the link above into go and js-ipfs |
Perhaps an unrelated issue, is that it looks like
|
import { outputFile } from 'fs-extra';
import fetchIPFS from 'fetch-ipfs';
import { statSync } from 'fs';
import { publishToIPFSAll } from 'fetch-ipfs/lib/put/all';
import { filterList } from 'ipfs-server-list';
console.log(`fs.stat`, statSync('./temp/111.png').size)
fetchIPFS(`QmdPAhQRxrDKqkGPvQzBvjYe3kU8kiEEAd2J6ETEamKAD9`)
.then(async (buf) => {
console.log(`fetch ipfs cid`, buf.length, `QmdPAhQRxrDKqkGPvQzBvjYe3kU8kiEEAd2J6ETEamKAD9`)
await publishToIPFSAll(buf, [
...filterList('API'),
])
.then(result => {
console.log(`add to ipfs again`, result[0].value[0].size, result[0].value[0].cid.toString());
})
;
return outputFile('./temp/111.png', buf)
})
.catch(e => console.trace(e))
; will see file size is not same
|
@aschmahmann i think not only dir, also happen on file |
Here is what I see: Bare filesystem$ ls -la dir
total 84992
drwxr-xr-x 4 alex staff 128 5 Aug 11:58 .
drwxr-xr-x 4 alex staff 128 5 Aug 13:25 ..
-rw-r--r-- 1 alex staff 20010278 5 Aug 11:58 hof.zip
-rw-r--r-- 1 alex staff 23016923 5 Aug 11:58 php-5.6.32-nts-Win32-VC11-x64.zip go-IPFSAdd the directory $ ipfs add -r dir
added QmYtpgcqDgsxrHhGN2f3xuD8Xw4TeXaVoseQbKJmMa3CBH dir/hof.zip
added QmPRnUadS9kozY1QrCjcYbg5smeAYrruniWQVgstNrv8a4 dir/php-5.6.32-nts-Win32-VC11-x64.zip
added QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn dir List the root dag $ ipfs ls /ipfs/QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
QmYtpgcqDgsxrHhGN2f3xuD8Xw4TeXaVoseQbKJmMa3CBH 20010278 hof.zip
QmPRnUadS9kozY1QrCjcYbg5smeAYrruniWQVgstNrv8a4 23016923 php-5.6.32-nts-Win32-VC11-x64.zip Stat the root of the dag $ ipfs files stat /ipfs/QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
Size: 0
CumulativeSize: 43037585
ChildBlocks: 2
Type: directory js-IPFSAdd the directory $ jsipfs add -r dir
added QmYtpgcqDgsxrHhGN2f3xuD8Xw4TeXaVoseQbKJmMa3CBH dir/hof.zip
added QmPRnUadS9kozY1QrCjcYbg5smeAYrruniWQVgstNrv8a4 dir/php-5.6.32-nts-Win32-VC11-x64.zip
added QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn dir List the root dag $ jsipfs ls /ipfs/QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
-rw-r--r-- - QmYtpgcqDgsxrHhGN2f3xuD8Xw4TeXaVoseQbKJmMa3CBH 20010278 hof.zip
-rw-r--r-- - QmPRnUadS9kozY1QrCjcYbg5smeAYrruniWQVgstNrv8a4 23016923 php-5.6.32-nts-Win32-VC11-x64.zip Stat the root of the dag $ jsipfs files stat /ipfs/QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
Size: 0
CumulativeSize: 43037585
ChildBlocks: 2
Type: directory
Mode: drwxr-xr-x
Mtime: - Everything seems in alignment. @aschmahmann what is @bluelovers the reason the sizes are different is the first is the size of the file, the second is the size of the dag that represents the file: $ ipfs files stat /ipfs/QmdPAhQRxrDKqkGPvQzBvjYe3kU8kiEEAd2J6ETEamKAD9
QmdPAhQRxrDKqkGPvQzBvjYe3kU8kiEEAd2J6ETEamKAD9
Size: 98734
CumulativeSize: 98748
ChildBlocks: 0
Type: file See I'm not familiar with the modules you are using in your example. If you can put an example together that only uses the |
@achingbrain it's the hash of the MFS root directory after manually copying in the two files into it. See the below walkthrough. Script of commands
Go-IPFS
JS-IPFS
|
import ipfsClient from 'ipfs-http-client';
import IPFS from 'ipfs';
const cid = `QmdPAhQRxrDKqkGPvQzBvjYe3kU8kiEEAd2J6ETEamKAD9`;
(async () =>
{
let ipfs = await ipfsClient({
port: 5001,
});
let ipfs2 = await IPFS.create();
await doTest(ipfs);
console.log(`--------------------`)
await doTest(ipfs2);
})();
async function doTest(ipfs)
{
let chunks: Buffer[] = [];
for await (let chunk of ipfs.cat(cid))
{
chunks.push(chunk)
}
let buf = Buffer.concat(chunks)
console.dir(buf.length)
for await (let ret of ipfs.addAll(buf))
{
console.log(ret)
}
}
|
Related ipld/explore.ipld.io#40 - ipld explorer always reports the size for dag-pb nodes as the value of node.size, it doesn't currently try to match the logic of |
Per @olizilla in ipld/explore.ipld.io#40 (comment)
Next actions:
|
js-ipfs is being deprecated in favor of Helia. You can learn more about this deprecation and read the migration guide. Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterwards (see #4336). FYI that share.ipfs.io will be migrating to Helia soon: ipfs-shipyard/ipfs-share-files#136 ipld-explorer-components and explore.ipld.io are already migrating off of js-ipfs: ipfs/ipld-explorer-components#360 |
Severity:
Description:
https://discuss.ipfs.io/t/why-has-same-sub-cids-but-not-same-root-cid/8810/3
Steps to reproduce the error:
upload file by ipds-desktop and https://share.ipfs.io/
The text was updated successfully, but these errors were encountered: