replace file_set_contents with replace_file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -12,7 +12,8 @@ use proxmox::api::{http_err, list_subdirs_api_method};
|
||||
use proxmox::api::{ApiResponseFuture, ApiHandler, ApiMethod, Router, RpcEnvironment, RpcEnvironmentType};
|
||||
use proxmox::api::router::SubdirMap;
|
||||
use proxmox::api::schema::*;
|
||||
use proxmox::tools::{try_block, fs::file_get_contents, fs::file_set_contents};
|
||||
use proxmox::tools::try_block;
|
||||
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
|
||||
use crate::api2::types::*;
|
||||
use crate::backup::*;
|
||||
@ -583,7 +584,7 @@ fn upload_backup_log(
|
||||
// always verify CRC at server side
|
||||
blob.verify_crc()?;
|
||||
let raw_data = blob.raw_data();
|
||||
file_set_contents(&path, raw_data, None)?;
|
||||
replace_file(&path, raw_data, CreateOptions::new())?;
|
||||
|
||||
// fixme: use correct formatter
|
||||
Ok(crate::server::formatter::json_response(Ok(Value::Null)))
|
||||
|
@ -4,10 +4,8 @@ use std::collections::HashMap;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::tools::{
|
||||
digest_to_hex,
|
||||
fs::file_set_contents,
|
||||
};
|
||||
use proxmox::tools::digest_to_hex;
|
||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||
use proxmox::api::{RpcEnvironment, RpcEnvironmentType};
|
||||
|
||||
use crate::server::WorkerTask;
|
||||
@ -415,7 +413,7 @@ impl BackupEnvironment {
|
||||
blob.verify_crc()?;
|
||||
|
||||
let raw_data = blob.raw_data();
|
||||
file_set_contents(&path, raw_data, None)?;
|
||||
replace_file(&path, raw_data, CreateOptions::new())?;
|
||||
|
||||
self.log(format!("add blob {:?} ({} bytes, comp: {})", path, orig_len, blob_len));
|
||||
|
||||
|
@ -9,7 +9,7 @@ use serde_json::{json, Value};
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment};
|
||||
use proxmox::api::schema::*;
|
||||
use proxmox::tools::fs::{file_get_contents, file_set_contents};
|
||||
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
use proxmox::tools::*; // required to use IPRE!() macro ???
|
||||
|
||||
use crate::api2::types::*;
|
||||
@ -91,7 +91,7 @@ fn update_dns(
|
||||
data.push('\n');
|
||||
}
|
||||
|
||||
file_set_contents(RESOLV_CONF_FN, data.as_bytes(), None)?;
|
||||
replace_file(RESOLV_CONF_FN, data.as_bytes(), CreateOptions::new())?;
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use serde_json::{json, Value};
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox::api::{ApiHandler, ApiMethod, Router, RpcEnvironment};
|
||||
use proxmox::api::schema::*;
|
||||
use proxmox::tools::fs::{file_read_firstline, file_set_contents};
|
||||
use proxmox::tools::fs::{file_read_firstline, replace_file, CreateOptions};
|
||||
|
||||
use crate::api2::types::*;
|
||||
|
||||
@ -71,7 +71,7 @@ fn set_timezone(
|
||||
bail!("No such timezone.");
|
||||
}
|
||||
|
||||
file_set_contents("/etc/timezone", timezone.as_bytes(), None)?;
|
||||
replace_file("/etc/timezone", timezone.as_bytes(), CreateOptions::new())?;
|
||||
|
||||
let _ = std::fs::remove_file("/etc/localtime");
|
||||
|
||||
|
Reference in New Issue
Block a user