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:
Con Kolivas 2015-04-16 16:38:20 +10:00
parent 788a70e6f6
commit fcb64e6dbb
2 changed files with 18 additions and 14 deletions

13
lrzip.c
View file

@ -311,7 +311,7 @@ int open_tmpoutfile(rzip_control *control)
fd_out = mkstemp(control->outfile);
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" : "");
} else
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);
}
if (unlikely(fd_in == -1))
fatal_return(("Failed to create in tmpfile: %s\n", control->infile), -1);
if (fd_in == -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);
/* Unlink temporary file immediately to minimise chance of files left
* lying around in cases of failure_return((. */
@ -466,6 +468,7 @@ int open_tmpinfile(rzip_control *control)
close(fd_in);
return -1;
}
}
return fd_in;
}
@ -490,6 +493,8 @@ bool read_tmpinfile(rzip_control *control, int fd_in)
FILE *tmpinfp;
int tmpchar;
if (fd_in == -1)
return false;
if (control->flags & FLAG_SHOW_PROGRESS)
fprintf(control->msgout, "Copying from stdin.\n");
tmpinfp = fdopen(fd_in, "w+");
@ -719,8 +724,6 @@ bool decompress_file(rzip_control *control)
if (STDIN) {
fd_in = open_tmpinfile(control);
if (unlikely(fd_in == -1))
return false;
read_tmpinmagic(control);
if (ENCRYPT)
failure_return(("Cannot decompress encrypted file from STDIN\n"), false);

View file

@ -703,7 +703,8 @@ ssize_t read_1g(rzip_control *control, int fd, void *buf, i64 len)
/* We're decompressing from STDIN */
if (unlikely(control->in_ofs + len > control->in_maxlen)) {
/* 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;
}
if (control->in_ofs + len > control->in_len) {