mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 485390, try #2 - when a .jar file doesn't exist yet, there's a race creating it, r=ted
This commit is contained in:
parent
f7437dbe2c
commit
faa05236ab
@ -257,13 +257,11 @@ class JarMaker(object):
|
||||
if self.outputFormat == 'jar':
|
||||
#jar
|
||||
jarfilepath = jarfile + '.jar'
|
||||
if os.path.isfile(jarfilepath) and \
|
||||
os.path.getsize(jarfilepath) > 0:
|
||||
jf = ZipFile(jarfilepath, 'a', lock = True)
|
||||
else:
|
||||
if not os.path.isdir(os.path.dirname(jarfilepath)):
|
||||
os.makedirs(os.path.dirname(jarfilepath))
|
||||
jf = ZipFile(jarfilepath, 'w', lock = True)
|
||||
try:
|
||||
os.makedirs(os.path.dirname(jarfilepath))
|
||||
except OSError:
|
||||
pass
|
||||
jf = ZipFile(jarfilepath, 'a', lock = True)
|
||||
outHelper = self.OutputHelper_jar(jf)
|
||||
else:
|
||||
outHelper = getattr(self, 'OutputHelper_' + self.outputFormat)(jarfile)
|
||||
|
@ -39,9 +39,9 @@ import zipfile
|
||||
import time
|
||||
import binascii, struct
|
||||
import zlib
|
||||
import os
|
||||
from utils import lockFile
|
||||
|
||||
|
||||
class ZipFile(zipfile.ZipFile):
|
||||
""" Class with methods to open, read, write, close, list zip files.
|
||||
|
||||
@ -55,6 +55,13 @@ class ZipFile(zipfile.ZipFile):
|
||||
self.lockfile = lockFile(file + '.lck')
|
||||
else:
|
||||
self.lockfile = None
|
||||
|
||||
if mode == 'a' and lock:
|
||||
# appending to a file which doesn't exist fails, but we can't check
|
||||
# existence util we hold the lock
|
||||
if (not os.path.isfile(file)) or os.path.getsize(file) == 0:
|
||||
mode = 'w'
|
||||
|
||||
zipfile.ZipFile.__init__(self, file, mode, compression)
|
||||
self._remove = []
|
||||
self.end = self.fp.tell()
|
||||
|
Loading…
Reference in New Issue
Block a user