feat(backend): don't dump uploaded files to root of vault
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Put them into `_up_data` instead.
This commit is contained in:
parent
2cdaf794e4
commit
8a254f8be4
2 changed files with 13 additions and 4 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -10,4 +10,5 @@ upend.sqlite3
|
|||
/.pnpm
|
||||
/.cargo
|
||||
|
||||
example_vault/zb*
|
||||
example_vault/zb*
|
||||
example_vault/_up_data
|
||||
|
|
|
@ -35,6 +35,7 @@ mod db;
|
|||
|
||||
pub const FILE_MIME_KEY: &str = "FILE_MIME";
|
||||
const FILE_SIZE_KEY: &str = "FILE_SIZE";
|
||||
const INCOMING_DIRECTORY: &str = "_up_data";
|
||||
|
||||
pub struct FsStore {
|
||||
path: PathBuf,
|
||||
|
@ -396,8 +397,13 @@ impl FsStore {
|
|||
Ok(Some(upath))
|
||||
}
|
||||
BlobMode::Mirror => {
|
||||
let normalized_path = self.normalize_path(path).unwrap();
|
||||
let path = normalized_path.parent().unwrap();
|
||||
let path = self.normalize_path(path).unwrap();
|
||||
let path = path.parent().unwrap();
|
||||
let path = if path.ends_with(INCOMING_DIRECTORY) {
|
||||
path.parent().unwrap_or(path)
|
||||
} else {
|
||||
path
|
||||
};
|
||||
|
||||
let upath =
|
||||
iter::once("NATIVE".parse().unwrap())
|
||||
|
@ -687,7 +693,9 @@ impl UpStore for FsStore {
|
|||
addr_str
|
||||
};
|
||||
|
||||
let final_path = self.path.join(final_name);
|
||||
let incoming_path = self.path.join(INCOMING_DIRECTORY);
|
||||
fs::create_dir_all(&incoming_path).map_err(|e| StoreError::Unknown(e.to_string()))?;
|
||||
let final_path = incoming_path.join(final_name);
|
||||
blob.copy_to(&final_path)
|
||||
.map_err(|e| StoreError::Unknown(e.to_string()))?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue