mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-17 21:20:37 +00:00
Add etag to ListingObject
This commit is contained in:
@@ -385,6 +385,7 @@ impl RemoteStorage for AzureBlobStorage {
|
||||
.map(|k| ListingObject{
|
||||
key: self.name_to_relative_path(&k.name),
|
||||
last_modified: k.properties.last_modified.into(),
|
||||
etag: k.properties.etag.clone(),
|
||||
size: k.properties.content_length,
|
||||
}
|
||||
);
|
||||
@@ -450,6 +451,7 @@ impl RemoteStorage for AzureBlobStorage {
|
||||
Ok(ListingObject {
|
||||
key: key.to_owned(),
|
||||
last_modified: SystemTime::from(properties.last_modified),
|
||||
etag: properties.etag,
|
||||
size: properties.content_length,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -166,6 +166,7 @@ pub enum ListingMode {
|
||||
pub struct ListingObject {
|
||||
pub key: RemotePath,
|
||||
pub last_modified: SystemTime,
|
||||
pub etag: Etag,
|
||||
pub size: u64,
|
||||
}
|
||||
|
||||
|
||||
@@ -372,6 +372,7 @@ impl RemoteStorage for LocalFs {
|
||||
objects.push(ListingObject {
|
||||
key: key.clone(),
|
||||
last_modified: metadata.modified()?,
|
||||
etag: mock_etag(&metadata),
|
||||
size: metadata.len(),
|
||||
});
|
||||
}
|
||||
@@ -414,6 +415,7 @@ impl RemoteStorage for LocalFs {
|
||||
result.keys.push(ListingObject {
|
||||
key: RemotePath::from_string(&relative_key).unwrap(),
|
||||
last_modified: object.last_modified,
|
||||
etag: object.etag,
|
||||
size: object.size,
|
||||
});
|
||||
}
|
||||
@@ -457,6 +459,7 @@ impl RemoteStorage for LocalFs {
|
||||
Ok(ListingObject {
|
||||
key: key.clone(),
|
||||
last_modified: metadata.modified()?,
|
||||
etag: mock_etag(&metadata),
|
||||
size: metadata.len(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -588,11 +588,16 @@ impl RemoteStorage for S3Bucket {
|
||||
}
|
||||
};
|
||||
|
||||
let etag = object.e_tag.clone()
|
||||
.ok_or(DownloadError::Other(anyhow::anyhow!("Missing etag header")))?
|
||||
.into();
|
||||
|
||||
let size = object.size.unwrap_or(0) as u64;
|
||||
|
||||
result.keys.push(ListingObject{
|
||||
key,
|
||||
last_modified,
|
||||
etag,
|
||||
size,
|
||||
});
|
||||
if let Some(mut mk) = max_keys {
|
||||
@@ -690,11 +695,16 @@ impl RemoteStorage for S3Bucket {
|
||||
"head_object doesn't contain last_modified or content_length"
|
||||
)))?;
|
||||
};
|
||||
let etag = data
|
||||
.e_tag
|
||||
.ok_or(DownloadError::Other(anyhow::anyhow!("Missing etag header")))?
|
||||
.into();
|
||||
Ok(ListingObject {
|
||||
key: key.to_owned(),
|
||||
last_modified: SystemTime::try_from(last_modified).map_err(|e| {
|
||||
DownloadError::Other(anyhow!("can't convert time '{last_modified}': {e}"))
|
||||
})?,
|
||||
etag: etag,
|
||||
size: size as u64,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user