#include <boost/system/error_code.hpp>
#include <cassert>
+#include <cstdint>
#include <string>
#include "common/paths.h"
return true;
}
+bool CheckFreeSpace(const bf::path& backup_path, const bf::path& shared_path) {
+ int64_t shared_size = ci::GetDirectorySize(shared_path);
+ if (!ci::CheckFreeSpaceAtPath(shared_size, backup_path))
+ return false;
+
+ return true;
+}
+
} // namespace
namespace common_installer {
install_path_ = context_->GetPkgPath();
backup_path_ = GetBackupPathForPackagePath(context_->GetPkgPath());
+ if (!CheckFreeSpace(backup_path_, install_path_ / "shared")) {
+ LOG(ERROR) << "not enough space for backup";
+ return Step::Status::OUT_OF_SPACE;
+ }
+
return Status::OK;
}
const char kPackageUnpackDirPath[] = UNPACKDIR;
-bool CheckFreeSpaceAtPath(int64_t required_size,
- const boost::filesystem::path& target_location) {
- bs::error_code error;
- boost::filesystem::path root = target_location;
- while (!bf::exists(root) && root != root.root_path()) {
- root = root.parent_path();
- }
- if (!bf::exists(root)) {
- LOG(ERROR) << "No mount point for path: " << target_location;
- return false;
- }
- bf::space_info space_info = bf::space(root, error);
- if (error) {
- LOG(ERROR) << "Failed to get space_info: " << error.message();
- return false;
- }
-
- return (space_info.free >= static_cast<uint64_t>(required_size));
-}
-
} // namespace
namespace common_installer {
return size;
}
+bool CheckFreeSpaceAtPath(int64_t required_size,
+ const boost::filesystem::path& target_location) {
+ bs::error_code error;
+ boost::filesystem::path root = target_location;
+ while (!bf::exists(root) && root != root.root_path())
+ root = root.parent_path();
+
+ if (!bf::exists(root)) {
+ LOG(ERROR) << "No mount point for path: " << target_location;
+ return false;
+ }
+ bf::space_info space_info = bf::space(root, error);
+ if (error) {
+ LOG(ERROR) << "Failed to get space_info: " << error.message();
+ return false;
+ }
+
+ return (space_info.free >= static_cast<uint64_t>(required_size));
+}
+
boost::filesystem::path GenerateTmpDir(const bf::path &app_path) {
boost::filesystem::path install_tmp_dir;
boost::filesystem::path tmp_dir(app_path);
int64_t GetDirectorySize(const boost::filesystem::path& path);
+bool CheckFreeSpaceAtPath(int64_t required_size,
+ const boost::filesystem::path& target_location);
+
boost::filesystem::path GenerateTmpDir(const boost::filesystem::path& app_path);
boost::filesystem::path GenerateTemporaryPath(