Merge "Fix ExternalStorageProvider always throw exception when rename" am: 8883851c71

am: deb51d8489

Change-Id: I4411270b371f25d7a245f163db8d1a358426b6f2
This commit is contained in:
Jeff Sharkey
2018-09-26 09:56:21 -07:00
committed by android-build-merger

View File

@@ -236,6 +236,7 @@ public abstract class FileSystemProvider extends DocumentsProvider {
displayName = FileUtils.buildValidFatFilename(displayName);
final File before = getFileForDocId(docId);
final File beforeVisibleFile = getFileForDocId(docId, true);
final File after = FileUtils.buildUniqueFile(before.getParentFile(), displayName);
if (!before.renameTo(after)) {
throw new IllegalStateException("Failed to rename to " + after);
@@ -245,7 +246,6 @@ public abstract class FileSystemProvider extends DocumentsProvider {
onDocIdChanged(docId);
onDocIdChanged(afterDocId);
final File beforeVisibleFile = getFileForDocId(docId, true);
final File afterVisibleFile = getFileForDocId(afterDocId, true);
moveInMediaStore(beforeVisibleFile, afterVisibleFile);