commit: 47eedeb3ec092b6916e309a36adb3e9baee4024a
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 13 04:51:04 2015 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Sat Jun 13 04:51:19 2015 +0000
URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=47eedeb3
flocker.py: Adds file mode checking for get_file()
Ensures that the file being returned by get_file() is opened with
the correct mode.
layman/flocker.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/layman/flocker.py b/layman/flocker.py
index aa5f3f8..3b9df64 100644
--- a/layman/flocker.py
+++ b/layman/flocker.py
@@ -73,7 +73,8 @@ class FileLocker(object):
if mode not in ('r', 'w+'):
raise LockingException('Invalid mode %(mode)s' % {'mode': mode})
- if path not in self.files or self.files[path].closed:
+ if (path not in self.files or self.files[path].closed or
+ self.files[path].mode != mode):
self.files[path] = fileopen(path, mode)
f = self.files[path]