|
@@ -2040,7 +2040,37 @@ public class NativeAzureFileSystem extends FileSystem {
|
|
|
createPermissionStatus(FsPermission.getDefault()));
|
|
|
}
|
|
|
|
|
|
- store.updateFolderLastModifiedTime(parentKey, null);
|
|
|
+ if (store.isAtomicRenameKey(parentKey)) {
|
|
|
+ SelfRenewingLease lease = null;
|
|
|
+ try {
|
|
|
+ lease = leaseSourceFolder(parentKey);
|
|
|
+ store.updateFolderLastModifiedTime(parentKey, lease);
|
|
|
+ } catch (AzureException e) {
|
|
|
+ String errorCode = "";
|
|
|
+ try {
|
|
|
+ StorageException e2 = (StorageException) e.getCause();
|
|
|
+ errorCode = e2.getErrorCode();
|
|
|
+ } catch (Exception e3) {
|
|
|
+ // do nothing if cast fails
|
|
|
+ }
|
|
|
+ if (errorCode.equals("BlobNotFound")) {
|
|
|
+ throw new FileNotFoundException("Folder does not exist: " + parentKey);
|
|
|
+ }
|
|
|
+ LOG.warn("Got unexpected exception trying to get lease on "
|
|
|
+ + parentKey + ". " + e.getMessage());
|
|
|
+ throw e;
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (lease != null) {
|
|
|
+ lease.free();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.error("Unable to free lease on " + parentKey, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ store.updateFolderLastModifiedTime(parentKey, null);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|