Only ask to proceed if using --rm, otherwise just display warning. -f bypasses it all. More robust tests
This commit is contained in:
+4
-6
@@ -1677,17 +1677,13 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
/* init */
|
/* init */
|
||||||
assert(outFileName != NULL || suffix != NULL);
|
assert(outFileName != NULL || suffix != NULL);
|
||||||
if (outFileName != NULL) { /* output into a single destination (stdout typically) */
|
if (outFileName != NULL) { /* output into a single destination (stdout typically) */
|
||||||
if (nbFiles > 1) {
|
if (nbFiles > 1 && !prefs->overwrite) {
|
||||||
if (!strcmp (outFileName, stdoutmark)) {
|
if (!strcmp (outFileName, stdoutmark)) {
|
||||||
DISPLAY("zstd: WARNING: all input files will be processed and concatenated into stdout. ");
|
DISPLAY("zstd: WARNING: all input files will be processed and concatenated into stdout. ");
|
||||||
} else {
|
} else {
|
||||||
DISPLAY("zstd: WARNING: all input files will be processed and concatenated into a single output file: %s ", outFileName);
|
DISPLAY("zstd: WARNING: all input files will be processed and concatenated into a single output file: %s ", outFileName);
|
||||||
}
|
}
|
||||||
if (prefs->removeSrcFile && !prefs->overwrite) {
|
if (prefs->removeSrcFile) {
|
||||||
DISPLAY("\nYou must specify -f as well in order to execute this command with --rm. Aborting...");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY("Proceed? (y/n): ");
|
DISPLAY("Proceed? (y/n): ");
|
||||||
{
|
{
|
||||||
int ch = getchar();
|
int ch = getchar();
|
||||||
@@ -1700,6 +1696,8 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
ch = getchar();
|
ch = getchar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DISPLAY("\n");
|
||||||
|
}
|
||||||
ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName);
|
ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName);
|
||||||
if (ress.dstFile == NULL) { /* could not open outFileName */
|
if (ress.dstFile == NULL) { /* could not open outFileName */
|
||||||
error = 1;
|
error = 1;
|
||||||
|
|||||||
+22
-12
@@ -349,24 +349,34 @@ rm tmp*
|
|||||||
println "\n===> compress multiple files"
|
println "\n===> compress multiple files"
|
||||||
println hello > tmp1
|
println hello > tmp1
|
||||||
println world > tmp2
|
println world > tmp2
|
||||||
echo 'y' | zstd tmp1 tmp2 -o "$INTOVOID" -f # echo 'y' confirms the warning prompt
|
zstd tmp1 tmp2 -o "$INTOVOID" -f
|
||||||
echo 'y' | zstd tmp1 tmp2 -c | zstd -t
|
zstd tmp1 tmp2 -c | zstd -t
|
||||||
echo 'y' | zstd tmp1 tmp2 -o tmp.zst
|
zstd tmp1 tmp2 -o tmp.zst
|
||||||
test ! -f tmp1.zst
|
test ! -f tmp1.zst
|
||||||
test ! -f tmp2.zst
|
test ! -f tmp2.zst
|
||||||
zstd tmp1 tmp2
|
zstd tmp1 tmp2
|
||||||
zstd -t tmp1.zst tmp2.zst
|
zstd -t tmp1.zst tmp2.zst
|
||||||
zstd -dc tmp1.zst tmp2.zst
|
zstd -dc tmp1.zst tmp2.zst
|
||||||
echo 'y' | zstd tmp1.zst tmp2.zst -o "$INTOVOID" -f
|
zstd tmp1.zst tmp2.zst -o "$INTOVOID" -f
|
||||||
echo 'y' | zstd -d tmp1.zst tmp2.zst -o tmp
|
zstd -d tmp1.zst tmp2.zst -o tmp
|
||||||
touch tmpexists
|
touch tmpexists
|
||||||
echo 'y' | zstd tmp1 tmp2 -f -o tmpexists
|
zstd tmp1 tmp2 -f -o tmpexists
|
||||||
echo 'y' | zstd tmp1 tmp2 -o tmpexists && die "should have refused to overwrite"
|
zstd tmp1 tmp2 -o tmpexists && die "should have refused to overwrite"
|
||||||
zstd tmp1 tmp2 -o "$INTOVOID" --rm && die "should have refused to execute with --rm"
|
|
||||||
println gooder > tmp_rm1
|
println gooder > tmp_rm1
|
||||||
println boi > tmp_rm2
|
println boi > tmp_rm2
|
||||||
echo 'y' | zstd tmp_rm1 tmp_rm2 -o tmp_rm3.zst -f --rm
|
println worldly > tmp_rm3
|
||||||
rm tmp_rm3.zst
|
echo 'y' | zstd tmp_rm1 tmp_rm2 -o tmp_rm3.zst --rm # tests the warning prompt for --rm with multiple inputs into once source
|
||||||
|
test ! -f tmp_rm1
|
||||||
|
test ! -f tmp_rm2
|
||||||
|
cp tmp_rm3.zst tmp_rm4.zst
|
||||||
|
echo 'Y' | zstd -d tmp_rm3.zst tmp_rm4.zst -o tmp_rm_out --rm
|
||||||
|
test ! -f tmp_rm3.zst
|
||||||
|
test ! -f tmp_rm4.zst
|
||||||
|
echo 'yes' | zstd tmp_rm_out tmp_rm3 -c --rm
|
||||||
|
test ! -f tmp_rm_out
|
||||||
|
test ! -f tmp_rm3
|
||||||
|
println gooder > tmpexists1
|
||||||
|
zstd tmpexists1 tmpexists -c --rm -f
|
||||||
|
|
||||||
# Bug: PR #972
|
# Bug: PR #972
|
||||||
if [ "$?" -eq 139 ]; then
|
if [ "$?" -eq 139 ]; then
|
||||||
@@ -388,7 +398,7 @@ test -f tmp1
|
|||||||
test -f tmp2
|
test -f tmp2
|
||||||
test -f tmp3
|
test -f tmp3
|
||||||
println "compress tmp* into stdout > tmpall : "
|
println "compress tmp* into stdout > tmpall : "
|
||||||
echo 'y' | zstd -c tmp1 tmp2 tmp3 > tmpall
|
zstd -c tmp1 tmp2 tmp3 > tmpall
|
||||||
test -f tmpall # should check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
|
test -f tmpall # should check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
|
||||||
println "decompress tmpall* into stdout > tmpdec : "
|
println "decompress tmpall* into stdout > tmpdec : "
|
||||||
cp tmpall tmpall2
|
cp tmpall tmpall2
|
||||||
@@ -926,7 +936,7 @@ datagen | zstd -c | zstd -t
|
|||||||
println "\n===> golden files tests "
|
println "\n===> golden files tests "
|
||||||
|
|
||||||
zstd -t -r "$TESTDIR/golden-decompression"
|
zstd -t -r "$TESTDIR/golden-decompression"
|
||||||
echo 'y' | zstd -c -r "$TESTDIR/golden-compression" | zstd -t
|
zstd -c -r "$TESTDIR/golden-compression" | zstd -t
|
||||||
zstd -D "$TESTDIR/golden-dictionaries/http-dict-missing-symbols" "$TESTDIR/golden-compression/http" -c | zstd -D "$TESTDIR/golden-dictionaries/http-dict-missing-symbols" -t
|
zstd -D "$TESTDIR/golden-dictionaries/http-dict-missing-symbols" "$TESTDIR/golden-compression/http" -c | zstd -D "$TESTDIR/golden-dictionaries/http-dict-missing-symbols" -t
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user