Parcourir la source

Fix adding files in a network share

We cannot always rename read-only files on network shares,
so rename the temp file for a new loose object first, and
then set it as read-only.

Bug: 335388
Change-Id: Ie0350e032a97e0d09626d6143c5c692873a5f6a2
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
tags/v0.11.1
Robin Rosenberg il y a 13 ans
Parent
révision
c4c8d80fd3

+ 1
- 2
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java Voir le fichier

return InsertLooseObjectResult.EXISTS_PACKED; return InsertLooseObjectResult.EXISTS_PACKED;
} }


tmp.setReadOnly();

final File dst = fileFor(id); final File dst = fileFor(id);
if (dst.exists()) { if (dst.exists()) {
// We want to be extra careful and avoid replacing an object // We want to be extra careful and avoid replacing an object
return InsertLooseObjectResult.EXISTS_LOOSE; return InsertLooseObjectResult.EXISTS_LOOSE;
} }
if (tmp.renameTo(dst)) { if (tmp.renameTo(dst)) {
tmp.setReadOnly();
unpackedObjectCache.add(id); unpackedObjectCache.add(id);
return InsertLooseObjectResult.INSERTED; return InsertLooseObjectResult.INSERTED;
} }

Chargement…
Annuler
Enregistrer