Hi,
I'm using your crate, which perfectly meets my needs and works very well. However, I've encountered an issue with the include_filters
option when using both the CopyBuilder
and copy_dir_advanced
methods.
Here's my code:
fn folder_backup(settings: BackupConfig) -> anyhow::Result<()> {
let destination_path = PathBuf::from(&settings.backup_destination).join("emergency-backup");
info!(target: "general", "{:?}", settings.extension_type.iter().map(|ext| ".".to_owned() + ext.as_str()).collect::<Vec<_>>());
match copy_dir_advanced(&settings.backup_source,
destination_path, false, true,
true, vec!(),
if settings.extension_only { settings.extension_type.iter().map(|ext| ".".to_owned() + ext.as_str()).collect() } else { vec!() } ) {
Ok(_) => { Ok(()) }
Err(err) => { error!("{}", err.to_string()); bail!(FileTransferError) }
}
}
The printed line before the copy_dir_advanced
call shows:
2024-07-12 12:57:39 | INFO | path/to/file.rs:203 โ [".pdf", ".txt"]
I initially tried using the extension_type
vector directly (in "ext" format, without the leading dot). However, I saw an example in the documentation that used the dot before the extension, so I tried that as well, but it still doesn't work.
let destination_path = PathBuf::from(&settings.backup_destination).join("emergency-backup");
info!(target: "general", "{:?}", settings.extension_type.iter().map(|ext| ".".to_owned() + ext.as_str()).collect::<Vec<_>>());
let mut builder = CopyBuilder::new(&settings.backup_source, destination_path);
if settings.extension_only {
for ext in settings.extension_type {
builder = builder.with_include_filter(ext.as_str());
}
}
match builder.run() {
Ok(_) => { Ok(()) }
Err(err) => { error!("{}", err.to_string()); bail!(FileTransferError) }
}
Am I missing something?
Thank you in advance.
UPDATE
Running this code seems not working as well:
let mut builder = CopyBuilder::new(&settings.backup_source, destination_path)
.with_include_filter(".txt")
.with_include_filter(".pdf").run();