diff options
author | Bartosz Kosiorek <bartosz.kosiorek@tomtom.com> | 2019-03-08 13:53:35 (GMT) |
---|---|---|
committer | Bartosz Kosiorek <bartosz.kosiorek@tomtom.com> | 2019-03-18 16:55:35 (GMT) |
commit | 8634576dcb03087fc507b8012a47f1ecc852f65f (patch) | |
tree | 47418b14525ece43b52697e9a82c1129d157d813 /Source | |
parent | c7c6a4a2cc06fd22eeb1c545dba030eddf39363a (diff) | |
download | CMake-8634576dcb03087fc507b8012a47f1ecc852f65f.zip CMake-8634576dcb03087fc507b8012a47f1ecc852f65f.tar.gz CMake-8634576dcb03087fc507b8012a47f1ecc852f65f.tar.bz2 |
cmake: Don't interrupt archive creation if unable to read a file.
Rationale:
Currently during creation of archive by 'tar',
if error appears, it interrupt archive creation.
As a result only part of files are archived
This behaviour is not consistent with 'copy_directory', native 'tar'
and other command behaviour.
With this Merge Request this behaviour is fixed.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmArchiveWrite.cxx | 11 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 10 |
2 files changed, 9 insertions, 12 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 23be603..177ba02 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -179,12 +179,10 @@ cmArchiveWrite::~cmArchiveWrite() bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix, bool recursive) { - if (this->Okay()) { - if (!path.empty() && path.back() == '/') { - path.erase(path.size() - 1); - } - this->AddPath(path.c_str(), skip, prefix, recursive); + if (!path.empty() && path.back() == '/') { + path.erase(path.size() - 1); } + this->AddPath(path.c_str(), skip, prefix, recursive); return this->Okay(); } @@ -220,6 +218,7 @@ bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix, bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix) { + this->Error = ""; // Skip the file if we have no name for it. This may happen on a // top-level directory, which does not need to be included anyway. if (skip >= strlen(file)) { @@ -241,7 +240,7 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix) cm_archive_entry_copy_pathname(e, dest); if (archive_read_disk_entry_from_file(this->Disk, e, -1, nullptr) != ARCHIVE_OK) { - this->Error = "archive_read_disk_entry_from_file '"; + this->Error = "Unable to read from file '"; this->Error += file; this->Error += "': "; this->Error += cm_archive_error_string(this->Disk); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index d762106..41f8cf4 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1658,20 +1658,18 @@ bool cmSystemTools::CreateTar(const char* outFileName, a.SetMTime(mtime); a.SetVerbose(verbose); + bool tarCreatedSuccessfully = true; for (auto path : files) { if (cmSystemTools::FileIsFullPath(path)) { // Get the relative path to the file. path = cmSystemTools::RelativePath(cwd, path); } if (!a.Add(path)) { - break; + cmSystemTools::Error(a.GetError()); + tarCreatedSuccessfully = false; } } - if (!a) { - cmSystemTools::Error(a.GetError()); - return false; - } - return true; + return tarCreatedSuccessfully; #else (void)outFileName; (void)files; |