diff --git a/dali/daliadmin/daadmin.cpp b/dali/daliadmin/daadmin.cpp index e44576f539b..e456c541c58 100644 --- a/dali/daliadmin/daadmin.cpp +++ b/dali/daliadmin/daadmin.cpp @@ -2273,8 +2273,8 @@ void checkFileSizeOne(IUserDescriptor *user, const char *lfn, bool fix) Owned dFile = queryDistributedFileDirectory().lookup(dlfn, user, AccessMode::tbdRead, false, false, nullptr, defaultPrivilegedUser, 30000); // 30 sec timeout if (dFile) { - bool locked = false; - COnScopeExit ensureUnlock([&]() { if (locked) dFile->unlockProperties(); }); + bool fileLocked = false; + COnScopeExit ensureFileUnlock([&]() { if (fileLocked) dFile->unlockProperties(); }); if (dFile->querySuperFile()) WARNLOG("Skipping: file '%s' is a superfile", lfn); else @@ -2288,10 +2288,19 @@ void checkFileSizeOne(IUserDescriptor *user, const char *lfn, bool fix) { if (fix) { + COnScopeExit ensurePartUnlock([&]() { part.unlockProperties(); }); offset_t partSize; try { partSize = part.getFileSize(true, true); + if (!fileLocked) + { + // we lock the file once, so that the individual part lock/unlocks are effectively a NOP + dFile->lockProperties(30000); + fileLocked = true; + PROGLOG("File '%s' has missing @size attributes", lfn); + } + part.lockProperties(30000); } catch (IException *e) { @@ -2299,12 +2308,6 @@ void checkFileSizeOne(IUserDescriptor *user, const char *lfn, bool fix) e->Release(); continue; } - if (!locked) - { - part.lockProperties(30000); - locked = true; - PROGLOG("File '%s' has missing @size attributes", lfn); - } PROGLOG("Part %u: Setting @size to %" I64F "u", p+1, partSize); attrs.setPropInt64("@size", partSize); }