Skip to content

Commit 7bc551a

Browse files
authored
fix access checking bug and cleanup (#74)
seems to work, fingers crossed * fix access checking bug and cleanup * fix writability check
1 parent f0163f2 commit 7bc551a

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

stormdb/base.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,18 @@
1212

1313

1414
def check_destination_exists(dest):
15-
return(os.access, os.F_OK)
15+
return os.access(dest, os.F_OK)
1616

1717

1818
def check_destination_writable(dest):
19-
try:
20-
open(dest, 'w')
21-
except IOError:
22-
return False
23-
else:
24-
os.remove(dest)
19+
if (not check_destination_exists(dest)
20+
and os.access(os.path.dirname(dest), os.W_OK)):
2521
return True
22+
return False # don't bother checking for writability if exists
2623

2724

2825
def check_source_readable(source):
29-
try:
30-
fid = open(source, 'r')
31-
except IOError:
32-
return False
33-
else:
34-
fid.close()
35-
return True
26+
return os.access(source, os.R_OK)
3627

3728

3829
def enforce_path_exists(test_dir):

0 commit comments

Comments
 (0)