-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
flatfs stores files in blocks folder wit ha specific format that is explained in ipfs (next-to-last
explained in https://github.com/ipfs/go-ds-flatfs/blob/5b0a8b85445049bdf226091c2a4d14b259b7e8c2/readme.go#L11). I created the method below but it seems it has issues:
https://github.com/functionland/go-fula/blob/main/blox/blox.go#L374
// GetCidv1FromBlockFilename extracts CIDv1 from block filename
func (p *Blox) GetCidv1FromBlockFilename(filename string) (cid.Cid, error) {
// Implement the logic to extract CIDv1 from filename
// For example, you can use regular expressions or string manipulation
// This is just a placeholder implementation
// Adjust it according to your actual filename format
// Here's a sample implementation:
base := filepath.Base(filename)
b58 := "B" + strings.ToUpper(strings.TrimSuffix(base, filepath.Ext(base)))
cidV0, err := cid.Decode(b58)
if err != nil {
fmt.Println("Error encoding to cidV0:", err)
return cid.Cid{}, err
}
cidV1 := cid.NewCidV1(uint64(multicodec.DagPb), cidV0.Hash())
return cidV1, nil
}
For exmaple for the below filenames it cannot create the cid:
Mar 18 21:17:52 pool-4 go-fula[160692]: 2024-03-18T21:17:52.183Z ERROR fula/blox blox/blox.go:505 Error extracting CIDv1 from filename /uniondrive/ipfs_datastore/blocks/PU/DYQBWGIP2Y4K5N4JKPHH2TWLF4F7LKNTZF3SEOF2MBILVDRMRMWMPUY.data: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: Error encoding to cidV0: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: 2024-03-18T21:17:52.183Z ERROR fula/blox blox/blox.go:505 Error extracting CIDv1 from filename /uniondrive/ipfs_datastore/blocks/MQ/DYQPPDK3Q5KGOI5LAYKHWI3LZ3OLMRGEFRK75ZKLRGJDBGAQQI2JMQA.data: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: Error encoding to cidV0: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: 2024-03-18T21:17:52.183Z ERROR fula/blox blox/blox.go:505 Error extracting CIDv1 from filename /uniondrive/ipfs_datastore/blocks/U2/DYQL6GCHLZOWBBQEL5B4LYBPWIINNVFIVN6GCVTL6ZYP54VGIEUTU2I.data: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: Error encoding to cidV0: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: 2024-03-18T21:17:52.183Z ERROR fula/blox blox/blox.go:505 Error extracting CIDv1 from filename /uniondrive/ipfs_datastore/blocks/LS/DYQBWQRQRIAZZNGU7YRIUEKO5MM2VWWOOSU32YS5N35MAW6NQQ7MLSQ.data: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: Error encoding to cidV0: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: 2024-03-18T21:17:52.183Z ERROR fula/blox blox/blox.go:505 Error extracting CIDv1 from filename /uniondrive/ipfs_datastore/blocks/TW/DYQIKVANSVYVG53UKLK7JAYG2OEUGNQDIS37TNL3OKAGTNDGUFSUTWY.data: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Mar 18 21:17:52 pool-4 go-fula[160692]: Error encoding to cidV0: invalid cid: invalid cid: expected 1 as the cid version number, got: 30
Metadata
Metadata
Assignees
Labels
No labels