mirror of
https://github.com/OMGeeky/gdriver2.git
synced 2026-02-23 15:38:32 +01:00
fix change token not fetched
This commit is contained in:
@@ -20,12 +20,33 @@ pub struct Metadata {
|
||||
pub gid: u32,
|
||||
pub xattrs: BTreeMap<Vec<u8>, Vec<u8>>,
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
pub fn root() -> Self {
|
||||
Self {
|
||||
state: FileState::Root,
|
||||
size: 0,
|
||||
last_accessed: (0, 0),
|
||||
last_modified: (0, 0),
|
||||
last_metadata_changed: (0, 0),
|
||||
kind: FileKind::Directory,
|
||||
mode: 0,
|
||||
hardlinks: 0,
|
||||
uid: 0,
|
||||
gid: 0,
|
||||
xattrs: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_metadata_file(path: &Path) -> Result<Metadata> {
|
||||
debug!("Reading metadata file: {:?}", path);
|
||||
let reader = File::open(path)?;
|
||||
Ok(serde_json::from_reader(reader)?)
|
||||
}
|
||||
pub fn write_metadata_file(path: &Path, metadata: &Metadata) -> Result<()> {
|
||||
let reader = File::open(path)?;
|
||||
debug!("Writing metadata file: {:?}", path);
|
||||
let reader = File::create(path)?;
|
||||
Ok(serde_json::to_writer(reader, metadata)?)
|
||||
}
|
||||
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Serialize, Deserialize, Clone, Hash)]
|
||||
@@ -33,6 +54,7 @@ pub enum FileState {
|
||||
Downloaded,
|
||||
Cached,
|
||||
MetadataOnly,
|
||||
Root,
|
||||
}
|
||||
|
||||
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Serialize, Deserialize, Clone, Hash)]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::prelude::DriveId;
|
||||
use crate::prelude::*;
|
||||
use crate::project_dirs::PROJECT_DIRS;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -10,7 +10,24 @@ pub struct GDriverSettings {
|
||||
downloaded_path: PathBuf,
|
||||
data_path: PathBuf,
|
||||
}
|
||||
|
||||
impl GDriverSettings {
|
||||
#[instrument]
|
||||
pub fn initialize_dirs(&self) -> Result<()> {
|
||||
info!("Initializing dirs");
|
||||
let dirs = vec![
|
||||
&self.metadata_path,
|
||||
&self.cache_path,
|
||||
&self.downloaded_path,
|
||||
&self.data_path,
|
||||
];
|
||||
for dir in dirs {
|
||||
info!("Creating dir: {:?}", dir);
|
||||
std::fs::create_dir_all(dir)?;
|
||||
}
|
||||
info!("Dirs created");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
impl GDriverSettings {
|
||||
pub fn metadata_path(&self) -> &Path {
|
||||
&self.metadata_path
|
||||
|
||||
Reference in New Issue
Block a user