mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Don't grant write permissions when cloning git repo
It should be unnecessary, the read-only flag is set on packfiles by Git and doesn't cause problems deleting the folder normally, and someone's reported an error when granting permissions.
This commit is contained in:
@@ -38,19 +38,6 @@ namespace fs = boost::filesystem;
|
||||
namespace loot {
|
||||
GitHelper::GitHelper() : logger_(getLogger()) {}
|
||||
|
||||
GitHelper::~GitHelper() {
|
||||
if (data_.repo != nullptr) {
|
||||
std::string path = git_repository_path(data_.repo);
|
||||
|
||||
if (!path.empty()) {
|
||||
try {
|
||||
GrantWritePermissions(path);
|
||||
} catch (std::exception&) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GitHelper::GitData::GitData() :
|
||||
repo(nullptr),
|
||||
remote(nullptr),
|
||||
@@ -164,26 +151,6 @@ bool GitHelper::IsRepository(const boost::filesystem::path& path) {
|
||||
NULL) == 0;
|
||||
}
|
||||
|
||||
// Removes the read-only flag from some files in git repositories created by
|
||||
// libgit2.
|
||||
void GitHelper::GrantWritePermissions(const boost::filesystem::path& path) {
|
||||
if (logger_) {
|
||||
logger_->trace("Recursively setting write permission on directory: {}",
|
||||
path.string());
|
||||
}
|
||||
for (fs::recursive_directory_iterator it(path);
|
||||
it != fs::recursive_directory_iterator();
|
||||
++it) {
|
||||
if ((it->status().permissions() &
|
||||
(fs::owner_write | fs::group_write | fs::others_write)) == 0) {
|
||||
if (logger_) {
|
||||
logger_->trace("Setting write permission for: {}", it->path().string());
|
||||
}
|
||||
fs::permissions(it->path(), fs::add_perms | fs::owner_write);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GitHelper::DiffFileCallback(const git_diff_delta* delta,
|
||||
float progress,
|
||||
void* payload) {
|
||||
@@ -248,13 +215,9 @@ void GitHelper::Clone(const boost::filesystem::path& path,
|
||||
|
||||
if (logger_) {
|
||||
logger_->trace(
|
||||
"Target repo path not empty, renaming and moving previous content "
|
||||
"back in.");
|
||||
"Target repo path not empty, moving cloned files in.");
|
||||
}
|
||||
|
||||
GrantWritePermissions(path);
|
||||
GrantWritePermissions(repoPath);
|
||||
|
||||
std::vector<boost::filesystem::path> filenamesToMove;
|
||||
for (fs::directory_iterator it(repoPath);
|
||||
it != fs::directory_iterator();
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace loot {
|
||||
class GitHelper {
|
||||
public:
|
||||
GitHelper();
|
||||
~GitHelper();
|
||||
|
||||
void InitialiseOptions(const std::string& branch,
|
||||
const std::string& filenameToCheckout);
|
||||
|
||||
Reference in New Issue
Block a user