@@ -341,73 +341,6 @@ public boolean supportsAtomicCreateNewFile() {
341341 return supportsAtomicFileCreation == AtomicFileCreation .SUPPORTED ;
342342 }
343343
344- @ Override
345- @ SuppressWarnings ("boxing" )
346- /**
347- * {@inheritDoc}
348- * <p>
349- * An implementation of the File#createNewFile() semantics which works also
350- * on NFS. If the config option
351- * {@code core.supportsAtomicCreateNewFile = true} (which is the default)
352- * then simply File#createNewFile() is called.
353- *
354- * But if {@code core.supportsAtomicCreateNewFile = false} then after
355- * successful creation of the lock file a hard link to that lock file is
356- * created and the attribute nlink of the lock file is checked to be 2. If
357- * multiple clients manage to create the same lock file nlink would be
358- * greater than 2 showing the error.
359- *
360- * @see "https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html"
361- *
362- * @deprecated use {@link FS_POSIX#createNewFileAtomic(File)} instead
363- * @since 4.5
364- */
365- @ Deprecated
366- public boolean createNewFile (File lock ) throws IOException {
367- if (!lock .createNewFile ()) {
368- return false ;
369- }
370- if (supportsAtomicCreateNewFile ()) {
371- return true ;
372- }
373- Path lockPath = lock .toPath ();
374- Path link = null ;
375- FileStore store = null ;
376- try {
377- store = Files .getFileStore (lockPath );
378- } catch (SecurityException e ) {
379- return true ;
380- }
381- try {
382- Boolean canLink = CAN_HARD_LINK .computeIfAbsent (store ,
383- s -> Boolean .TRUE );
384- if (Boolean .FALSE .equals (canLink )) {
385- return true ;
386- }
387- link = Files .createLink (
388- Paths .get (lock .getAbsolutePath () + ".lnk" ), //$NON-NLS-1$
389- lockPath );
390- Integer nlink = (Integer ) Files .getAttribute (lockPath ,
391- "unix:nlink" ); //$NON-NLS-1$
392- if (nlink > 2 ) {
393- LOG .warn (MessageFormat .format (
394- JGitText .get ().failedAtomicFileCreation , lockPath ,
395- nlink ));
396- return false ;
397- } else if (nlink < 2 ) {
398- CAN_HARD_LINK .put (store , Boolean .FALSE );
399- }
400- return true ;
401- } catch (UnsupportedOperationException | IllegalArgumentException e ) {
402- CAN_HARD_LINK .put (store , Boolean .FALSE );
403- return true ;
404- } finally {
405- if (link != null ) {
406- Files .delete (link );
407- }
408- }
409- }
410-
411344 /**
412345 * {@inheritDoc}
413346 * <p>
0 commit comments