(File soDirectory, File lockFileName)
| 441 | } |
| 442 | |
| 443 | public static @Nullable FileLocker getOrCreateLockOnDir(File soDirectory, File lockFileName) |
| 444 | throws IOException { |
| 445 | boolean notWritable = false; |
| 446 | try { |
| 447 | return getFileLocker(lockFileName); |
| 448 | } catch (FileNotFoundException e) { |
| 449 | notWritable = true; |
| 450 | if (!soDirectory.setWritable(true)) { |
| 451 | throw e; |
| 452 | } |
| 453 | return getFileLocker(lockFileName); |
| 454 | } finally { |
| 455 | if (notWritable && !soDirectory.setWritable(false)) { |
| 456 | LogUtil.w(TAG, "error removing " + soDirectory.getCanonicalPath() + " write permission"); |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | public static FileLocker getFileLocker(File lockFileName) throws IOException { |
| 462 | return FileLocker.lock(lockFileName); |
no test coverage detected