mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Do not fail if we are unable to write temporary files, giving a warning only that it might fail if we don't have enough ram
This commit is contained in:
parent
788a70e6f6
commit
fcb64e6dbb
13
lrzip.c
13
lrzip.c
|
|
@ -311,7 +311,7 @@ int open_tmpoutfile(rzip_control *control)
|
||||||
|
|
||||||
fd_out = mkstemp(control->outfile);
|
fd_out = mkstemp(control->outfile);
|
||||||
if (fd_out == -1) {
|
if (fd_out == -1) {
|
||||||
print_verbose("WARNING: Failed to create out tmpfile: %s , will fail if cannot perform entirely in ram\n",
|
print_progress("WARNING: Failed to create out tmpfile: %s, will fail if cannot perform %scompression entirely in ram\n",
|
||||||
control->outfile, DECOMPRESS ? "de" : "");
|
control->outfile, DECOMPRESS ? "de" : "");
|
||||||
} else
|
} else
|
||||||
register_outfile(control, control->outfile, TEST_ONLY || STDOUT || !KEEP_BROKEN);
|
register_outfile(control, control->outfile, TEST_ONLY || STDOUT || !KEEP_BROKEN);
|
||||||
|
|
@ -456,8 +456,10 @@ int open_tmpinfile(rzip_control *control)
|
||||||
fd_in = mkstemp(control->infile);
|
fd_in = mkstemp(control->infile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(fd_in == -1))
|
if (fd_in == -1) {
|
||||||
fatal_return(("Failed to create in tmpfile: %s\n", control->infile), -1);
|
print_progress("WARNING: Failed to create in tmpfile: %s, will fail if cannot perform %scompression entirely in ram\n",
|
||||||
|
control->infile, DECOMPRESS ? "de" : "");
|
||||||
|
} else {
|
||||||
register_infile(control, control->infile, (DECOMPRESS || TEST_ONLY) && STDIN);
|
register_infile(control, control->infile, (DECOMPRESS || TEST_ONLY) && STDIN);
|
||||||
/* Unlink temporary file immediately to minimise chance of files left
|
/* Unlink temporary file immediately to minimise chance of files left
|
||||||
* lying around in cases of failure_return((. */
|
* lying around in cases of failure_return((. */
|
||||||
|
|
@ -466,6 +468,7 @@ int open_tmpinfile(rzip_control *control)
|
||||||
close(fd_in);
|
close(fd_in);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return fd_in;
|
return fd_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -490,6 +493,8 @@ bool read_tmpinfile(rzip_control *control, int fd_in)
|
||||||
FILE *tmpinfp;
|
FILE *tmpinfp;
|
||||||
int tmpchar;
|
int tmpchar;
|
||||||
|
|
||||||
|
if (fd_in == -1)
|
||||||
|
return false;
|
||||||
if (control->flags & FLAG_SHOW_PROGRESS)
|
if (control->flags & FLAG_SHOW_PROGRESS)
|
||||||
fprintf(control->msgout, "Copying from stdin.\n");
|
fprintf(control->msgout, "Copying from stdin.\n");
|
||||||
tmpinfp = fdopen(fd_in, "w+");
|
tmpinfp = fdopen(fd_in, "w+");
|
||||||
|
|
@ -719,8 +724,6 @@ bool decompress_file(rzip_control *control)
|
||||||
|
|
||||||
if (STDIN) {
|
if (STDIN) {
|
||||||
fd_in = open_tmpinfile(control);
|
fd_in = open_tmpinfile(control);
|
||||||
if (unlikely(fd_in == -1))
|
|
||||||
return false;
|
|
||||||
read_tmpinmagic(control);
|
read_tmpinmagic(control);
|
||||||
if (ENCRYPT)
|
if (ENCRYPT)
|
||||||
failure_return(("Cannot decompress encrypted file from STDIN\n"), false);
|
failure_return(("Cannot decompress encrypted file from STDIN\n"), false);
|
||||||
|
|
|
||||||
3
stream.c
3
stream.c
|
|
@ -703,7 +703,8 @@ ssize_t read_1g(rzip_control *control, int fd, void *buf, i64 len)
|
||||||
/* We're decompressing from STDIN */
|
/* We're decompressing from STDIN */
|
||||||
if (unlikely(control->in_ofs + len > control->in_maxlen)) {
|
if (unlikely(control->in_ofs + len > control->in_maxlen)) {
|
||||||
/* We're unable to fit it all into the temp buffer */
|
/* We're unable to fit it all into the temp buffer */
|
||||||
dump_stdin(control);
|
if (dump_stdin(control))
|
||||||
|
failure_return(("Inadequate ram to %compress from STDIN and unable to create in tmpfile"), -1);
|
||||||
goto read_fd;
|
goto read_fd;
|
||||||
}
|
}
|
||||||
if (control->in_ofs + len > control->in_len) {
|
if (control->in_ofs + len > control->in_len) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue