Commit 3371f7cb authored by Julian Hofer's avatar Julian Hofer
Browse files

Merge branch 'copy_remove_file_download' into 'master'

Copy cache across filesystems

Closes #127

See merge request !180
parents 3a3e1785 d38a5f1b
Pipeline #243315 passed with stages
in 31 minutes and 37 seconds
......@@ -25,7 +25,7 @@ use reqwest::redirect::Policy;
use tempdir::TempDir;
use std::fs;
use std::fs::{rename, DirBuilder, File};
use std::fs::{copy, remove_file, DirBuilder, File};
use std::io::{BufWriter, Read, Write};
use std::path::Path;
use std::sync::{Arc, Mutex};
......@@ -129,7 +129,10 @@ fn download_into(
// Construct the desired path.
let target = format!("{}/{}.{}", dir, file_title, ext);
// Rename/move the tempfile into a permanent place upon success.
rename(out_file, &target)?;
// Unlike rename(), copy() + remove_file() works even when the
// temp dir is on a different mount point than the target dir.
copy(&out_file, &target)?;
remove_file(out_file)?;
info!("Downloading of {} completed successfully.", &target);
Ok(target)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment