equal
deleted
inserted
replaced
242 target = pycompat.fsencode(os.path.basename(fd.name)) |
242 target = pycompat.fsencode(os.path.basename(fd.name)) |
243 else: |
243 else: |
244 # create a fixed file to link to; doesn't matter if it |
244 # create a fixed file to link to; doesn't matter if it |
245 # already exists. |
245 # already exists. |
246 target = 'checklink-target' |
246 target = 'checklink-target' |
247 open(os.path.join(cachedir, target), 'w').close() |
247 try: |
|
248 open(os.path.join(cachedir, target), 'w').close() |
|
249 except IOError as inst: |
|
250 if inst[0] == errno.EACCES: |
|
251 # If we can't write to cachedir, just pretend |
|
252 # that the fs is readonly and by association |
|
253 # that the fs won't support symlinks. This |
|
254 # seems like the least dangerous way to avoid |
|
255 # data loss. |
|
256 return False |
|
257 raise |
248 try: |
258 try: |
249 os.symlink(target, name) |
259 os.symlink(target, name) |
250 if cachedir is None: |
260 if cachedir is None: |
251 unlink(name) |
261 unlink(name) |
252 else: |
262 else: |