mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
assert that vfile rename/move/delete should happen in a write action
This commit is contained in:
@@ -208,6 +208,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
|
||||
* @throws IOException if file failed to be renamed
|
||||
*/
|
||||
public void rename(Object requestor, @NotNull String newName) throws IOException {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
if (getName().equals(newName)) return;
|
||||
if (!getFileSystem().isValidName(newName)) {
|
||||
throw new IOException(VfsBundle.message("file.invalid.name.error", newName));
|
||||
@@ -451,6 +452,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
|
||||
* @throws IOException if file failed to be deleted
|
||||
*/
|
||||
public void delete(Object requestor) throws IOException {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
LOG.assertTrue(isValid(), "Deleting invalid file");
|
||||
getFileSystem().deleteFile(requestor, this);
|
||||
}
|
||||
@@ -466,6 +468,8 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
|
||||
* @throws IOException if file failed to be moved
|
||||
*/
|
||||
public void move(final Object requestor, @NotNull final VirtualFile newParent) throws IOException {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
|
||||
if (getFileSystem() != newParent.getFileSystem()) {
|
||||
throw new IOException(VfsBundle.message("file.move.error", newParent.getPresentableUrl()));
|
||||
}
|
||||
|
||||
+7
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.vfs.newvfs.impl;
|
||||
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.io.FileTooBigException;
|
||||
@@ -201,11 +202,13 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
|
||||
@Override
|
||||
public void delete(final Object requestor) throws IOException {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
ourPersistence.deleteFile(requestor, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(final Object requestor, @NotNull @NonNls final String newName) throws IOException {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
if (getName().equals(newName)) return;
|
||||
validateName(newName);
|
||||
ourPersistence.renameFile(requestor, this, newName);
|
||||
@@ -258,6 +261,8 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
|
||||
@Override
|
||||
public void move(final Object requestor, @NotNull final VirtualFile newParent) throws IOException {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
|
||||
if (getFileSystem() != newParent.getFileSystem()) {
|
||||
throw new IOException(VfsBundle.message("file.move.error", newParent.getPresentableUrl()));
|
||||
}
|
||||
@@ -323,6 +328,8 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile {
|
||||
}
|
||||
|
||||
public void setParent(@NotNull VirtualFile newParent) {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
|
||||
VirtualDirectoryImpl parent = getParent();
|
||||
parent.removeChild(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user