refactor: if the file exists locally, pull from out own node before fetching it from the net

This commit is contained in:
Derrick Hammer 2024-03-07 16:59:50 -05:00
parent e489de1e86
commit 4261bb6a5d
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 0 deletions

View File

@ -309,6 +309,20 @@ func (f *S5File) Manifest() (s5libmetadata.Metadata, error) {
cid = f.CID() cid = f.CID()
} }
if f.Exists() {
data, err := io.ReadAll(f)
if err != nil {
return nil, err
}
md, err := f.protocol.Node().Services().Storage().ParseMetadata(data, cid)
if err != nil {
return nil, err
}
return md, nil
}
meta, err := f.protocol.Node().Services().Storage().GetMetadataByCID(cid) meta, err := f.protocol.Node().Services().Storage().GetMetadataByCID(cid)
if err != nil { if err != nil {
return nil, err return nil, err