mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
Fix exception when making a directory that already exists
Summary: There was a race condition where there could be an exception when trying to create directories that already exist. Test Plan: Ran the tests Reviewers: #sourcecontrol, ttung Differential Revision: https://phabricator.fb.com/D2736268
This commit is contained in:
parent
7431e97098
commit
2b30eeb96b
@ -19,7 +19,11 @@ fetchmisses = 0
|
||||
_downloading = _('downloading')
|
||||
|
||||
def makedirs(root, path, owner):
|
||||
os.makedirs(path)
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError, ex:
|
||||
if ex.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
while path != root:
|
||||
stat = os.stat(path)
|
||||
|
@ -6,7 +6,7 @@
|
||||
# GNU General Public License version 2 or any later version.
|
||||
|
||||
import fileserverclient
|
||||
import collections, os, shutil
|
||||
import collections, errno, os, shutil
|
||||
from mercurial.node import bin, hex, nullid, nullrev
|
||||
from mercurial import revlog, mdiff, filelog, ancestor, error
|
||||
from mercurial.i18n import _
|
||||
@ -28,7 +28,11 @@ def _readfile(path):
|
||||
def _writefile(path, content):
|
||||
dirname = os.path.dirname(path)
|
||||
if not os.path.exists(dirname):
|
||||
os.makedirs(dirname)
|
||||
try:
|
||||
os.makedirs(dirname)
|
||||
except OSError, ex:
|
||||
if ex.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
f = open(path, "w")
|
||||
try:
|
||||
|
@ -12,7 +12,7 @@ from mercurial.hgweb import protocol as httpprotocol
|
||||
from mercurial.node import bin, hex, nullid, nullrev
|
||||
from mercurial.i18n import _
|
||||
import shallowrepo
|
||||
import stat, os, lz4, time
|
||||
import errno, stat, os, lz4, time
|
||||
|
||||
try:
|
||||
from mercurial import streamclone
|
||||
@ -207,7 +207,12 @@ def _loadfileblob(repo, cachepath, path, node):
|
||||
try:
|
||||
dirname = os.path.dirname(filecachepath)
|
||||
if not os.path.exists(dirname):
|
||||
os.makedirs(dirname)
|
||||
try:
|
||||
os.makedirs(dirname)
|
||||
except OSError, ex:
|
||||
if ex.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
f = None
|
||||
try:
|
||||
f = util.atomictempfile(filecachepath, "w")
|
||||
|
Loading…
Reference in New Issue
Block a user