Skip to content

Commit

Permalink
Check if the cachedir exists (if it's required)
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Apr 7, 2024
1 parent 0bb00d0 commit b3c8074
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tar/bsdtar.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ __FBSDID("$FreeBSD: src/usr.bin/tar/bsdtar.c,v 1.93 2008/11/08 04:43:24 kientzle
#include <assert.h>

#include "bsdtar.h"
#include "chunks.h"
#include "crypto.h"
#include "dirutil.h"
#include "humansize.h"
Expand Down Expand Up @@ -987,6 +988,25 @@ main(int argc, char **argv)
bsdtar_errc(bsdtar, 1, 0,
"Cache directory must be specified for %s",
bsdtar->modestr);
if (bsdtar->mode == 'd' ||
bsdtar->mode == OPTION_RECOVER ||
bsdtar->mode == OPTION_PRINT_STATS) {
switch (chunks_directory_exists(bsdtar->cachedir)) {
case 1:
/* Exists; good. */
break;
case 0:
/* Does not exist; error and exit. */
bsdtar_errc(bsdtar, 1, 0,
"Cache directory must already exist for %s;"
" check --cachedir and/or run --fsck",
bsdtar->modestr);
case -1:
/* Could not check; error and exit. */
bsdtar_errc(bsdtar, 1, errno,
"Could not check if cachedir exists");
}
}
if (tarsnap_opt_aggressive_networking != 0) {
if ((bsdtar->bwlimit_rate_up != 0) ||
(bsdtar->bwlimit_rate_down != 0)) {
Expand Down

0 comments on commit b3c8074

Please sign in to comment.