Merge "Call access(2) on all files/dirs modified by Mtp" into pi-dev
This commit is contained in:
@@ -35,6 +35,9 @@ import android.provider.MediaStore;
|
|||||||
import android.provider.MediaStore.Audio;
|
import android.provider.MediaStore.Audio;
|
||||||
import android.provider.MediaStore.Files;
|
import android.provider.MediaStore.Files;
|
||||||
import android.provider.MediaStore.MediaColumns;
|
import android.provider.MediaStore.MediaColumns;
|
||||||
|
import android.system.ErrnoException;
|
||||||
|
import android.system.Os;
|
||||||
|
import android.system.OsConstants;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -560,6 +563,13 @@ public class MtpDatabase implements AutoCloseable {
|
|||||||
return MtpConstants.RESPONSE_GENERAL_ERROR;
|
return MtpConstants.RESPONSE_GENERAL_ERROR;
|
||||||
Path newPath = obj.getPath();
|
Path newPath = obj.getPath();
|
||||||
boolean success = oldPath.toFile().renameTo(newPath.toFile());
|
boolean success = oldPath.toFile().renameTo(newPath.toFile());
|
||||||
|
try {
|
||||||
|
Os.access(oldPath.toString(), OsConstants.F_OK);
|
||||||
|
Os.access(newPath.toString(), OsConstants.F_OK);
|
||||||
|
} catch (ErrnoException e) {
|
||||||
|
// Ignore. Could fail if the metadata was already updated.
|
||||||
|
}
|
||||||
|
|
||||||
if (!mManager.endRenameObject(obj, oldPath.getFileName().toString(), success)) {
|
if (!mManager.endRenameObject(obj, oldPath.getFileName().toString(), success)) {
|
||||||
Log.e(TAG, "Failed to end rename object");
|
Log.e(TAG, "Failed to end rename object");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,10 @@ public class MtpStorageManagerTest {
|
|||||||
mainStorageDir = createNewDir(TEMP_DIR_FILE);
|
mainStorageDir = createNewDir(TEMP_DIR_FILE);
|
||||||
secondaryStorageDir = createNewDir(TEMP_DIR_FILE);
|
secondaryStorageDir = createNewDir(TEMP_DIR_FILE);
|
||||||
|
|
||||||
StorageVolume mainStorage = new StorageVolume("1", mainStorageDir, "", true, false, true,
|
StorageVolume mainStorage = new StorageVolume("1", mainStorageDir, mainStorageDir,
|
||||||
false, -1, UserHandle.CURRENT, "", "");
|
"", true, false, true, false, -1, UserHandle.CURRENT, "", "");
|
||||||
StorageVolume secondaryStorage = new StorageVolume("2", secondaryStorageDir, "", false,
|
StorageVolume secondaryStorage = new StorageVolume("2", secondaryStorageDir,
|
||||||
false, true, false, -1, UserHandle.CURRENT, "", "");
|
secondaryStorageDir, "", false, false, true, false, -1, UserHandle.CURRENT, "", "");
|
||||||
|
|
||||||
objectsAdded = new ArrayList<>();
|
objectsAdded = new ArrayList<>();
|
||||||
objectsRemoved = new ArrayList<>();
|
objectsRemoved = new ArrayList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user