update to nix 0.14, use code from proxmox:tools
This commit is contained in:
@ -12,6 +12,8 @@ use chrono::{DateTime, Datelike, TimeZone, Local};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use proxmox::tools::{try_block, fs::file_set_contents};
|
||||
|
||||
use crate::config::datastore;
|
||||
|
||||
use crate::backup::*;
|
||||
@ -510,7 +512,7 @@ fn upload_backup_log(
|
||||
// always comput CRC at server side
|
||||
blob.set_crc(blob.compute_crc());
|
||||
let raw_data = blob.raw_data();
|
||||
crate::tools::file_set_contents(&path, raw_data, None)?;
|
||||
file_set_contents(&path, raw_data, None)?;
|
||||
Ok(())
|
||||
})
|
||||
.and_then(move |_| {
|
||||
|
@ -4,7 +4,10 @@ use std::collections::HashMap;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::tools;
|
||||
use proxmox::tools::{
|
||||
digest_to_hex,
|
||||
fs::file_set_contents,
|
||||
};
|
||||
|
||||
use crate::api_schema::router::{RpcEnvironment, RpcEnvironmentType};
|
||||
use crate::server::WorkerTask;
|
||||
@ -298,8 +301,8 @@ impl BackupEnvironment {
|
||||
|
||||
fn log_upload_stat(&self, archive_name: &str, csum: &[u8; 32], uuid: &[u8; 16], size: u64, chunk_count: u64, upload_stat: &UploadStatistic) {
|
||||
self.log(format!("Upload statistics for '{}'", archive_name));
|
||||
self.log(format!("UUID: {}", tools::digest_to_hex(uuid)));
|
||||
self.log(format!("Checksum: {}", tools::digest_to_hex(csum)));
|
||||
self.log(format!("UUID: {}", digest_to_hex(uuid)));
|
||||
self.log(format!("Checksum: {}", digest_to_hex(csum)));
|
||||
self.log(format!("Size: {}", size));
|
||||
self.log(format!("Chunk count: {}", chunk_count));
|
||||
|
||||
@ -402,7 +405,7 @@ impl BackupEnvironment {
|
||||
blob.set_crc(blob.compute_crc());
|
||||
|
||||
let raw_data = blob.raw_data();
|
||||
crate::tools::file_set_contents(&path, raw_data, None)?;
|
||||
file_set_contents(&path, raw_data, None)?;
|
||||
|
||||
self.log(format!("add blob {:?} ({} bytes, comp: {})", path, orig_len, blob_len));
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
use failure::*;
|
||||
|
||||
|
||||
use crate::tools;
|
||||
use proxmox::tools::fs::{file_get_contents, file_set_contents};
|
||||
use crate::api2::*;
|
||||
use crate::api_schema::*;
|
||||
//use crate::api_schema::router::*;
|
||||
@ -23,7 +22,7 @@ fn read_etc_resolv_conf() -> Result<Value, Error> {
|
||||
|
||||
let mut nscount = 0;
|
||||
|
||||
let raw = tools::file_get_contents(RESOLV_CONF_FN)?;
|
||||
let raw = file_get_contents(RESOLV_CONF_FN)?;
|
||||
|
||||
result["digest"] = Value::from(proxmox::tools::digest_to_hex(&sha::sha256(&raw)));
|
||||
|
||||
@ -63,13 +62,13 @@ fn update_dns(
|
||||
|
||||
let _guard = MUTEX.lock();
|
||||
|
||||
let search = tools::required_string_param(¶m, "search")?;
|
||||
let search = crate::tools::required_string_param(¶m, "search")?;
|
||||
|
||||
let raw = tools::file_get_contents(RESOLV_CONF_FN)?;
|
||||
let raw = file_get_contents(RESOLV_CONF_FN)?;
|
||||
let old_digest = proxmox::tools::digest_to_hex(&sha::sha256(&raw));
|
||||
|
||||
if let Some(digest) = param["digest"].as_str() {
|
||||
tools::assert_if_modified(&old_digest, &digest)?;
|
||||
crate::tools::assert_if_modified(&old_digest, &digest)?;
|
||||
}
|
||||
|
||||
let old_data = String::from_utf8(raw)?;
|
||||
@ -92,7 +91,7 @@ fn update_dns(
|
||||
data.push('\n');
|
||||
}
|
||||
|
||||
tools::file_set_contents(RESOLV_CONF_FN, data.as_bytes(), None)?;
|
||||
file_set_contents(RESOLV_CONF_FN, data.as_bytes(), None)?;
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use failure::*;
|
||||
use proxmox::tools::fs::{file_read_firstline, file_set_contents};
|
||||
|
||||
use crate::tools;
|
||||
use crate::api_schema::*;
|
||||
use crate::api_schema::router::*;
|
||||
use crate::api2::types::*;
|
||||
@ -11,7 +11,7 @@ use chrono::prelude::*;
|
||||
|
||||
fn read_etc_localtime() -> Result<String, Error> {
|
||||
// use /etc/timezone
|
||||
if let Ok(line) = tools::file_read_firstline("/etc/timezone") {
|
||||
if let Ok(line) = file_read_firstline("/etc/timezone") {
|
||||
return Ok(line.trim().to_owned());
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ fn set_timezone(
|
||||
_rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let timezone = tools::required_string_param(¶m, "timezone")?;
|
||||
let timezone = crate::tools::required_string_param(¶m, "timezone")?;
|
||||
|
||||
let path = std::path::PathBuf::from(format!("/usr/share/zoneinfo/{}", timezone));
|
||||
|
||||
@ -64,7 +64,7 @@ fn set_timezone(
|
||||
bail!("No such timezone.");
|
||||
}
|
||||
|
||||
tools::file_set_contents("/etc/timezone", timezone.as_bytes(), None)?;
|
||||
file_set_contents("/etc/timezone", timezone.as_bytes(), None)?;
|
||||
|
||||
let _ = std::fs::remove_file("/etc/localtime");
|
||||
|
||||
|
Reference in New Issue
Block a user