Better cache locking semantics

This commit is contained in:
Сергей Конев 2024-10-31 18:26:09 +03:00
parent 510a48ecb3
commit 3f5a452133

View File

@ -201,12 +201,6 @@ PCache *pkg_cache_create() {
#else
const char *to_c_string(std::string s);
#include <unistd.h>
bool can_commit() {
// Allow user with effective SU to acquire lock
return geteuid() == 0;
}
// See ALT's apt/cmdline
// Used to print out the progress
@ -214,12 +208,9 @@ bool can_commit() {
ostream progress_stream(0);
PCache *pkg_cache_create() {
// Maybe should be set to false sometimes
// (Set to can_commit() for now)
// We should lock for installation, etc.
// For read-only access no locking needed
// In apt-shell, WithLock is always set according to (geteuid() == 0).
const bool WithLock = can_commit();
const bool WithLock = false;
CacheFile *cache_file = new CacheFile(progress_stream, WithLock);
cache_file->Open();