feat: add proof download s5 protocol file discovery

This commit is contained in:
Derrick Hammer 2024-02-09 15:55:04 -05:00
parent 0c00e2e7d9
commit a4afda0ecc
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 12 additions and 1 deletions

View File

@ -232,7 +232,7 @@ func (s S5ProviderStore) Provide(hash *encoding.Multihash, kind []types.StorageL
case types.StorageLocationTypeArchive: case types.StorageLocationTypeArchive:
return s5storage.NewStorageLocation(int(types.StorageLocationTypeArchive), []string{}, calculateExpiry(24*time.Hour)), nil return s5storage.NewStorageLocation(int(types.StorageLocationTypeArchive), []string{}, calculateExpiry(24*time.Hour)), nil
case types.StorageLocationTypeFile, types.StorageLocationTypeFull: case types.StorageLocationTypeFile, types.StorageLocationTypeFull:
return s5storage.NewStorageLocation(int(types.StorageLocationTypeFull), []string{generateDownloadUrl(hash, s.config, s.logger)}, calculateExpiry(24*time.Hour)), nil return s5storage.NewStorageLocation(int(types.StorageLocationTypeFull), []string{generateDownloadUrl(hash, s.config, s.logger), generateProofUrl(hash, s.config, s.logger)}, calculateExpiry(24*time.Hour)), nil
} }
} }
@ -257,3 +257,14 @@ func generateDownloadUrl(hash *encoding.Multihash, config *viper.Viper, logger *
return fmt.Sprintf("https://s5.%s/s5/download/%s", domain, hashStr) return fmt.Sprintf("https://s5.%s/s5/download/%s", domain, hashStr)
} }
func generateProofUrl(hash *encoding.Multihash, config *viper.Viper, logger *zap.Logger) string {
domain := config.GetString("core.domain")
hashStr, err := hash.ToBase64Url()
if err != nil {
logger.Error("error encoding hash", zap.Error(err))
}
return fmt.Sprintf("https://s5.%s/s5/download/%s.obao", domain, hashStr)
}