let ChunkStore::create take CreateOptions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
47d4712152
commit
afdcfb5bc9
|
@ -5,6 +5,7 @@ use serde_json::{json, Value};
|
||||||
|
|
||||||
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment};
|
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment};
|
||||||
use proxmox::api::schema::*;
|
use proxmox::api::schema::*;
|
||||||
|
use proxmox::tools::fs::CreateOptions;
|
||||||
|
|
||||||
use crate::api2::types::*;
|
use crate::api2::types::*;
|
||||||
use crate::backup::*;
|
use crate::backup::*;
|
||||||
|
@ -54,7 +55,14 @@ fn create_datastore(
|
||||||
}
|
}
|
||||||
|
|
||||||
let path: PathBuf = param["path"].as_str().unwrap().into();
|
let path: PathBuf = param["path"].as_str().unwrap().into();
|
||||||
let _store = ChunkStore::create(name, path)?;
|
let backup_user = crate::backup::backup_user()?;
|
||||||
|
let _store = ChunkStore::create(
|
||||||
|
name,
|
||||||
|
path,
|
||||||
|
CreateOptions::new()
|
||||||
|
.owner(backup_user.uid)
|
||||||
|
.group(backup_user.gid),
|
||||||
|
)?;
|
||||||
|
|
||||||
let datastore = json!({
|
let datastore = json!({
|
||||||
"path": param["path"]
|
"path": param["path"]
|
||||||
|
|
|
@ -85,7 +85,10 @@ impl ChunkStore {
|
||||||
chunk_dir
|
chunk_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create<P: Into<PathBuf>>(name: &str, path: P) -> Result<Self, Error> {
|
pub fn create<P>(name: &str, path: P, options: CreateOptions) -> Result<Self, Error>
|
||||||
|
where
|
||||||
|
P: Into<PathBuf>,
|
||||||
|
{
|
||||||
|
|
||||||
let base: PathBuf = path.into();
|
let base: PathBuf = path.into();
|
||||||
|
|
||||||
|
@ -95,12 +98,6 @@ impl ChunkStore {
|
||||||
|
|
||||||
let chunk_dir = Self::chunk_dir(&base);
|
let chunk_dir = Self::chunk_dir(&base);
|
||||||
|
|
||||||
let backup_user = crate::backup::backup_user()?;
|
|
||||||
|
|
||||||
let options = CreateOptions::new()
|
|
||||||
.owner(backup_user.uid)
|
|
||||||
.group(backup_user.gid);
|
|
||||||
|
|
||||||
let default_options = CreateOptions::new();
|
let default_options = CreateOptions::new();
|
||||||
|
|
||||||
if let Err(err) = create_path(&base, Some(default_options.clone()), Some(options.clone())) {
|
if let Err(err) = create_path(&base, Some(default_options.clone()), Some(options.clone())) {
|
||||||
|
@ -464,7 +461,7 @@ fn test_chunk_store1() {
|
||||||
let chunk_store = ChunkStore::open("test", &path);
|
let chunk_store = ChunkStore::open("test", &path);
|
||||||
assert!(chunk_store.is_err());
|
assert!(chunk_store.is_err());
|
||||||
|
|
||||||
let chunk_store = ChunkStore::create("test", &path).unwrap();
|
let chunk_store = ChunkStore::create("test", &path, CreateOptions::new()).unwrap();
|
||||||
|
|
||||||
let (chunk, digest) = super::DataChunkBuilder::new(&[0u8, 1u8]).build().unwrap();
|
let (chunk, digest) = super::DataChunkBuilder::new(&[0u8, 1u8]).build().unwrap();
|
||||||
|
|
||||||
|
@ -475,7 +472,7 @@ fn test_chunk_store1() {
|
||||||
assert!(exists);
|
assert!(exists);
|
||||||
|
|
||||||
|
|
||||||
let chunk_store = ChunkStore::create("test", &path);
|
let chunk_store = ChunkStore::create("test", &path, CreateOptions::new());
|
||||||
assert!(chunk_store.is_err());
|
assert!(chunk_store.is_err());
|
||||||
|
|
||||||
if let Err(_e) = std::fs::remove_dir_all(".testdir") { /* ignore */ }
|
if let Err(_e) = std::fs::remove_dir_all(".testdir") { /* ignore */ }
|
||||||
|
|
Loading…
Reference in New Issue