rename filesystem-sync option to filesystem-sync-time

This commit is contained in:
postscriptum 2025-07-05 23:01:08 +03:00
parent fabc11f9cb
commit fd102a9715
3 changed files with 8 additions and 8 deletions

View file

@ -64,8 +64,8 @@ snac2nex -s /path/to/snac/storage -t /path/to/nex -u user1 -u user2
[default: "%Y/%m/%d %H:%M:%S"] [default: "%Y/%m/%d %H:%M:%S"]
--filesystem-sync --filesystem-sync-time
Sync filesystem meta (e.g. time modified) Sync file meta with Snac entry time (e.g. time modified)
--filesystem-file-permissions <FILESYSTEM_FILE_PERMISSIONS> --filesystem-file-permissions <FILESYSTEM_FILE_PERMISSIONS>
Set new file permissions (macos, linux only) Set new file permissions (macos, linux only)

View file

@ -48,9 +48,9 @@ pub struct Config {
#[arg(long, default_value_t = String::from("%Y/%m/%d %H:%M:%S"))] #[arg(long, default_value_t = String::from("%Y/%m/%d %H:%M:%S"))]
pub format_updated: String, pub format_updated: String,
/// Sync filesystem meta (e.g. time modified) /// Sync file meta with Snac entry time (e.g. time modified)
#[arg(long, default_value_t = false)] #[arg(long, default_value_t = false)]
pub filesystem_sync: bool, pub filesystem_sync_time: bool,
/// Set new file permissions (macos, linux only) /// Set new file permissions (macos, linux only)
#[arg(long, value_parser = permissions)] #[arg(long, value_parser = permissions)]

View file

@ -22,7 +22,7 @@ pub struct Nex {
filename: String, filename: String,
is_cleanup: bool, is_cleanup: bool,
is_debug: bool, is_debug: bool,
is_filesystem_sync: bool, is_filesystem_sync_time: bool,
template: Template, template: Template,
users: HashMap<String, PathBuf>, users: HashMap<String, PathBuf>,
} }
@ -71,7 +71,7 @@ impl Nex {
filename: config.format_filename.clone(), filename: config.format_filename.clone(),
is_cleanup: !config.keep, is_cleanup: !config.keep,
is_debug: !config.daemon, is_debug: !config.daemon,
is_filesystem_sync: config.filesystem_sync, is_filesystem_sync_time: config.filesystem_sync_time,
template, template,
users, users,
}) })
@ -189,7 +189,7 @@ impl Nex {
.sync( .sync(
&from, &from,
&to, &to,
if self.is_filesystem_sync { if self.is_filesystem_sync_time {
Some(timestamp.into()) Some(timestamp.into())
} else { } else {
None None
@ -290,7 +290,7 @@ impl Nex {
}; };
let mut f = fs::File::create(path)?; let mut f = fs::File::create(path)?;
f.write_all(data)?; f.write_all(data)?;
if self.is_filesystem_sync { if self.is_filesystem_sync_time {
f.set_modified((*modified).into())?; // it's important to call after write f.set_modified((*modified).into())?; // it's important to call after write
} }
if let Some(ref p) = self.file_permissions { if let Some(ref p) = self.file_permissions {