From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-811719-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 7ED72138CE7
	for <garchives@archives.gentoo.org>; Sat, 13 Jun 2015 04:53:48 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id AC8ABE087D;
	Sat, 13 Jun 2015 04:53:44 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 5EC85E087D
	for <gentoo-commits@lists.gentoo.org>; Sat, 13 Jun 2015 04:53:44 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 2F9733406C0
	for <gentoo-commits@lists.gentoo.org>; Sat, 13 Jun 2015 04:53:43 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id B84FAA13
	for <gentoo-commits@lists.gentoo.org>; Sat, 13 Jun 2015 04:53:41 +0000 (UTC)
From: "Devan Franchini" <twitch153@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" <twitch153@gentoo.org>
Message-ID: <1434171079.47eedeb3ec092b6916e309a36adb3e9baee4024a.twitch153@gentoo>
Subject: [gentoo-commits] proj/layman:master commit in: layman/
X-VCS-Repository: proj/layman
X-VCS-Files: layman/flocker.py
X-VCS-Directories: layman/
X-VCS-Committer: twitch153
X-VCS-Committer-Name: Devan Franchini
X-VCS-Revision: 47eedeb3ec092b6916e309a36adb3e9baee4024a
X-VCS-Branch: master
Date: Sat, 13 Jun 2015 04:53:41 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 7781fe5b-6308-4dbc-a7a1-f7dfed69951a
X-Archives-Hash: a706bfc7cf8f562299027d77c22e01fd

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]