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
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.zipgo-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 dirList the root dag $ ipfs ls /ipfs/QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
QmYtpgcqDgsxrHhGN2f3xuD8Xw4TeXaVoseQbKJmMa3CBH 20010278 hof.zip
QmPRnUadS9kozY1QrCjcYbg5smeAYrruniWQVgstNrv8a4 23016923 php-5.6.32-nts-Win32-VC11-x64.zipStat the root of the dag $ ipfs files stat /ipfs/QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
QmdvbTgdaoqYV2rmh6raYT5pWZ7Lujhz73M6xtaRcC5xXn
Size: 0
CumulativeSize: 43037585
ChildBlocks: 2
Type: directoryjs-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 dirList 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.zipStat 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: fileSee 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 |
bluelovers commentedAug 4, 2020
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: