Allow ignoring copying errors due to existing files when moving packages
This commit is contained in:
parent
8949b5f3c1
commit
b3b396df5f
|
@ -47,7 +47,14 @@ BuildActionMetaInfo::BuildActionMetaInfo()
|
|||
.category = "Repo management",
|
||||
.name = "Move packages",
|
||||
.type = "move-packages",
|
||||
.flags = {},
|
||||
.flags = {
|
||||
BuildActionFlagMetaInfo{
|
||||
.id = static_cast<BuildActionFlagType>(MovePackagesFlags::IgnoreExistingFiles),
|
||||
.name = "Ignore existing files",
|
||||
.desc = "Ignore copying errors caused by already existing files in the destination repository",
|
||||
.param = "ignore-existing-files",
|
||||
},
|
||||
},
|
||||
.settings = {},
|
||||
.directory = true,
|
||||
.sourceDb = true,
|
||||
|
|
|
@ -51,6 +51,10 @@ enum class BuildActionType : std::uint64_t {
|
|||
|
||||
using BuildActionFlagType = std::uint64_t;
|
||||
constexpr BuildActionFlagType noBuildActionFlags = 0;
|
||||
enum class MovePackagesFlags : BuildActionFlagType {
|
||||
None,
|
||||
IgnoreExistingFiles = (1 << 0),
|
||||
};
|
||||
enum class CheckForUpdatesFlags : BuildActionFlagType {
|
||||
None,
|
||||
ConsiderRegularPackage = (1 << 0), // be consistent with LibPkg::UpdateCheckOptions here
|
||||
|
@ -183,6 +187,7 @@ inline const BuildActionTypeMetaMapping &BuildActionMetaInfo::mappingForId(Build
|
|||
|
||||
} // namespace LibRepoMgr
|
||||
|
||||
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(LibRepoMgr, LibRepoMgr::MovePackagesFlags)
|
||||
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(LibRepoMgr, LibRepoMgr::ReloadDatabaseFlags)
|
||||
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(LibRepoMgr, LibRepoMgr::ReloadLibraryDependenciesFlags)
|
||||
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(LibRepoMgr, LibRepoMgr::PrepareBuildFlags)
|
||||
|
|
|
@ -354,6 +354,7 @@ private:
|
|||
void conclude();
|
||||
|
||||
std::string m_addErrorMessage;
|
||||
LibRepoMgr::MovePackagesFlags m_options = LibRepoMgr::MovePackagesFlags::None;
|
||||
};
|
||||
|
||||
struct LIBREPOMGR_EXPORT UpdateCheck : public InternalBuildAction {
|
||||
|
|
|
@ -231,6 +231,9 @@ MovePackages::MovePackages(ServiceSetup &setup, const std::shared_ptr<BuildActio
|
|||
|
||||
void MovePackages::run()
|
||||
{
|
||||
const auto flags = static_cast<CheckForUpdatesFlags>(m_buildAction->flags);
|
||||
m_options = static_cast<LibRepoMgr::MovePackagesFlags>(flags);
|
||||
|
||||
if (!prepareRepoAction(RequiredDatabases::OneSource | RequiredDatabases::OneDestination)) {
|
||||
return;
|
||||
}
|
||||
|
@ -270,9 +273,13 @@ void MovePackages::run()
|
|||
}
|
||||
}
|
||||
} catch (const std::filesystem::filesystem_error &e) {
|
||||
ok = false;
|
||||
m_result.failedPackages.emplace_back(packageName, argsToString("unable to copy to destination repo: ", e.what()));
|
||||
continue;
|
||||
const auto ignoreError = (m_options & MovePackagesFlags::IgnoreExistingFiles)
|
||||
&& (e.code() == std::errc::file_exists || e.code() == std::errc::invalid_argument);
|
||||
if (!ignoreError) {
|
||||
ok = false;
|
||||
m_result.failedPackages.emplace_back(packageName, argsToString("unable to copy to destination repo: ", e.what()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
m_fileNames.emplace_back(packageLocation.pathWithinRepo.filename());
|
||||
m_result.processedPackages.emplace_back(packageName);
|
||||
|
|
Loading…
Reference in New Issue