sharing: cosmetics + replace pop/append by inline adjust
This commit is contained in:
@@ -198,7 +198,7 @@ class Sharing(sharing.BaseSharing):
|
||||
pass
|
||||
else:
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
logger.debug("TRACE/sharing/list/row: add: %r", row)
|
||||
logger.debug("TRACE/sharing/list/row: add : %r", row)
|
||||
result.append(row)
|
||||
index += 1
|
||||
return result
|
||||
@@ -317,7 +317,7 @@ class Sharing(sharing.BaseSharing):
|
||||
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
logger.debug("TRACE/sharing/%s/update: OwnerOrUser=%r PathOrToken=%r index=%d", ShareType, OwnerOrUser, PathOrToken, index)
|
||||
logger.debug("TRACE/sharing/%s/update: orig row=%r", ShareType, row)
|
||||
logger.debug("TRACE/sharing/%s/update: orig row[%d]=%r", ShareType, index, row)
|
||||
|
||||
# CSV: remove+adjust+readd
|
||||
if PathMapped is not None:
|
||||
@@ -336,11 +336,10 @@ class Sharing(sharing.BaseSharing):
|
||||
row["TimestampUpdated"] = Timestamp
|
||||
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
logger.debug("TRACE/sharing/%s/update: adj row=%r", ShareType, row)
|
||||
logger.debug("TRACE/sharing/%s/update: adj row[%d]=%r", ShareType, index, row)
|
||||
|
||||
# replace row
|
||||
self._sharing_cache.pop(index)
|
||||
self._sharing_cache.append(row)
|
||||
self._sharing_cache[index] = row
|
||||
|
||||
with self._storage.acquire_lock("w", OwnerOrUser, path=self._sharing_db_file):
|
||||
if self._write_csv(self._sharing_db_file):
|
||||
@@ -485,10 +484,8 @@ class Sharing(sharing.BaseSharing):
|
||||
|
||||
row['TimestampUpdated'] = Timestamp
|
||||
|
||||
# remove
|
||||
self._sharing_cache.pop(index)
|
||||
# readd
|
||||
self._sharing_cache.append(row)
|
||||
# replace
|
||||
self._sharing_cache[index] = row
|
||||
|
||||
with self._storage.acquire_lock("w", OwnerOrUser, path=self._sharing_db_file):
|
||||
if self._write_csv(self._sharing_db_file):
|
||||
@@ -523,7 +520,7 @@ class Sharing(sharing.BaseSharing):
|
||||
if fieldname not in row:
|
||||
logger.debug("sharing database is incompatible: %r", file)
|
||||
return False
|
||||
# convert txt to bool
|
||||
# convert txt to bool or int
|
||||
if self._lines > 0:
|
||||
for fieldname in sharing.DB_FIELDS_V1_BOOL:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user