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