src/backup/chunk_store.rs - create: pass User instead of CreateOptions

This commit is contained in:
Dietmar Maurer 2019-12-20 09:11:40 +01:00
parent bca9093520
commit e67770d496
2 changed files with 6 additions and 9 deletions

View File

@ -5,7 +5,6 @@ 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::*;
@ -61,13 +60,7 @@ fn create_datastore(
let path: PathBuf = param["path"].as_str().unwrap().into(); let path: PathBuf = param["path"].as_str().unwrap().into();
let backup_user = crate::backup::backup_user()?; let backup_user = crate::backup::backup_user()?;
let _store = ChunkStore::create( let _store = ChunkStore::create(name, path, backup_user)?;
name,
path,
CreateOptions::new()
.owner(backup_user.uid)
.group(backup_user.gid),
)?;
let datastore = json!({ let datastore = json!({
"path": param["path"], "path": param["path"],

View File

@ -85,7 +85,7 @@ impl ChunkStore {
chunk_dir chunk_dir
} }
pub fn create<P>(name: &str, path: P, options: CreateOptions) -> Result<Self, Error> pub fn create<P>(name: &str, path: P, user: nix::unistd::User) -> Result<Self, Error>
where where
P: Into<PathBuf>, P: Into<PathBuf>,
{ {
@ -98,6 +98,10 @@ impl ChunkStore {
let chunk_dir = Self::chunk_dir(&base); let chunk_dir = Self::chunk_dir(&base);
let options = CreateOptions::new()
.owner(user.uid)
.group(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())) {