mirror of
https://github.com/akuker/RASCSI.git
synced 2025-02-16 19:31:09 +00:00
Unlink created image file if fallocate() or copying failed (#363)
* Unlink created image file if fallocate() failed * Also delete destination file after copying if something goes wrong
This commit is contained in:
parent
269b718ec7
commit
ac4abbbe73
@ -151,6 +151,8 @@ bool RascsiImage::CreateImage(int fd, const PbCommand& command)
|
||||
if (fallocate(image_fd, 0, 0, len) == -1) {
|
||||
close(image_fd);
|
||||
|
||||
unlink(filename.c_str());
|
||||
|
||||
return ReturnStatus(fd, false, "Can't allocate space for image file '" + filename + "': " + string(strerror(errno)));
|
||||
}
|
||||
|
||||
@ -297,6 +299,8 @@ bool RascsiImage::CopyImage(int fd, const PbCommand& command)
|
||||
close(fd_dst);
|
||||
close(fd_src);
|
||||
|
||||
unlink(to.c_str());
|
||||
|
||||
return ReturnStatus(fd, false, "Can't copy image file '" + from + "' to '" + to + "': " + string(strerror(errno)));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user