Skip to content

Commit 462251c

Browse files
committed
Skip missing files in retire_deltas()
1 parent 528ffef commit 462251c

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jobs/update_repo_job.rs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,23 @@ impl UpdateRepoJobInstance {
145145
if dst.exists() {
146146
fs::remove_dir_all(&dst)?;
147147
}
148-
fs::rename(&src, &dst)?;
149-
150-
/* Update mtime so we can use it to trigger deletion */
151-
filetime::set_file_times(&dst, now_filetime, now_filetime)?;
148+
match fs::rename(&src, &dst) {
149+
Ok(_) => {
150+
filetime::set_file_times(&dst, now_filetime, now_filetime)?;
151+
}
152+
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
153+
job_log_and_info!(
154+
self.job_id,
155+
conn,
156+
&format!(
157+
" Delta {:?} already removed, skipping",
158+
src.strip_prefix(&deltas_dir).unwrap()
159+
),
160+
);
161+
continue;
162+
}
163+
Err(e) => return Err(e.into()),
164+
}
152165
}
153166

154167
/* Delete all temporary deltas older than one hour */
@@ -179,7 +192,20 @@ impl UpdateRepoJobInstance {
179192
dir.strip_prefix(&tmp_deltas_dir).unwrap()
180193
),
181194
);
182-
fs::remove_dir_all(&dir)?;
195+
match fs::remove_dir_all(&dir) {
196+
Ok(_) => {}
197+
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
198+
job_log_and_info!(
199+
self.job_id,
200+
conn,
201+
&format!(
202+
" Old delta {:?} already removed, skipping",
203+
dir.strip_prefix(&tmp_deltas_dir).unwrap()
204+
),
205+
);
206+
}
207+
Err(e) => return Err(e.into()),
208+
}
183209
}
184210

185211
Ok(())

0 commit comments

Comments
 (0)