fix: uploads via API are assigned paths like via FS
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
d23d02413e
commit
e41960230f
|
@ -556,7 +556,15 @@ pub async fn put_blob(
|
|||
let _store = state.store.clone();
|
||||
let _filename = filename.clone();
|
||||
let hash = web::block(move || {
|
||||
_store.store(connection, Blob::from_filepath(file.path()), _filename)
|
||||
let options = connection.get_vault_options()?;
|
||||
_store
|
||||
.store(
|
||||
connection,
|
||||
Blob::from_filepath(file.path()),
|
||||
_filename,
|
||||
options.blob_mode,
|
||||
)
|
||||
.map_err(anyhow::Error::from)
|
||||
})
|
||||
.await?
|
||||
.map_err(ErrorInternalServerError)?;
|
||||
|
|
|
@ -648,6 +648,7 @@ impl UpStore for FsStore {
|
|||
connection: UpEndConnection,
|
||||
blob: Blob,
|
||||
name_hint: Option<String>,
|
||||
blob_mode: Option<BlobMode>,
|
||||
) -> Result<UpMultihash, super::StoreError> {
|
||||
let file_path = blob.get_file_path();
|
||||
let hash = hash_at_path(file_path).map_err(|e| StoreError::Unknown(e.to_string()))?;
|
||||
|
@ -671,6 +672,13 @@ impl UpStore for FsStore {
|
|||
let final_path = self.path.join(final_name);
|
||||
fs::copy(file_path, &final_path).map_err(|e| StoreError::Unknown(e.to_string()))?;
|
||||
|
||||
let upath = if let Some(bm) = blob_mode {
|
||||
self.path_to_upath(&final_path, bm)
|
||||
.map_err(|e| StoreError::Unknown(e.to_string()))?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let metadata =
|
||||
fs::metadata(&final_path).map_err(|e| StoreError::Unknown(e.to_string()))?;
|
||||
let size = metadata.len() as i64;
|
||||
|
@ -688,7 +696,7 @@ impl UpStore for FsStore {
|
|||
self.insert_file_with_metadata(
|
||||
&connection,
|
||||
&final_path,
|
||||
None,
|
||||
upath,
|
||||
hash.clone(),
|
||||
name_hint,
|
||||
size,
|
||||
|
|
|
@ -60,6 +60,7 @@ pub trait UpStore {
|
|||
connection: UpEndConnection,
|
||||
blob: Blob,
|
||||
name_hint: Option<String>,
|
||||
blob_mode: Option<BlobMode>,
|
||||
) -> Result<UpMultihash>;
|
||||
fn update(
|
||||
&self,
|
||||
|
|
Loading…
Reference in New Issue