Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee6820ef60
|
||
|
|
1951fcda8a
|
@@ -1,3 +1,9 @@
|
|||||||
|
- 0.2.7
|
||||||
|
* Handle missing files in fs readdir list
|
||||||
|
- 0.2.6
|
||||||
|
* Ensure atomic state lock in fs
|
||||||
|
- 0.2.5
|
||||||
|
* Correct handling of persistent sync when no not-state filter has been set
|
||||||
- 0.2.4
|
- 0.2.4
|
||||||
* Add optional concurrency lock for persistence store, implemented for file store
|
* Add optional concurrency lock for persistence store, implemented for file store
|
||||||
- 0.2.3
|
- 0.2.3
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = shep
|
name = shep
|
||||||
version = 0.2.5
|
version = 0.2.7
|
||||||
description = Multi-state key stores using bit masks
|
description = Multi-state key stores using bit masks
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
|||||||
@@ -28,22 +28,17 @@ class SimpleFileStore:
|
|||||||
os.makedirs(lock_path, exist_ok=True)
|
os.makedirs(lock_path, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def __is_locked(self, k):
|
|
||||||
if self.__lock_path == None:
|
|
||||||
return False
|
|
||||||
for v in os.listdir(self.__lock_path):
|
|
||||||
if k == v:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def __lock(self, k):
|
def __lock(self, k):
|
||||||
if self.__lock_path == None:
|
if self.__lock_path == None:
|
||||||
return
|
return
|
||||||
if self.__is_locked(k):
|
|
||||||
raise StateLockedKey(k)
|
|
||||||
fp = os.path.join(self.__lock_path, k)
|
fp = os.path.join(self.__lock_path, k)
|
||||||
f = open(fp, 'w')
|
f = None
|
||||||
|
try:
|
||||||
|
f = open(fp, 'x')
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
if f == None:
|
||||||
|
raise StateLockedKey(k)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
@@ -120,7 +115,11 @@ class SimpleFileStore:
|
|||||||
files = []
|
files = []
|
||||||
for p in os.listdir(self.__path):
|
for p in os.listdir(self.__path):
|
||||||
fp = os.path.join(self.__path, p)
|
fp = os.path.join(self.__path, p)
|
||||||
f = open(fp, self.__m[0])
|
f = None
|
||||||
|
try:
|
||||||
|
f = open(fp, self.__m[0])
|
||||||
|
except FileNotFoundError:
|
||||||
|
continue
|
||||||
r = f.read()
|
r = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
if len(r) == 0:
|
if len(r) == 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user