mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
[429668] - Avoid race condition causing mkdir to fail.
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
3faf39df8d
commit
1b500f829b
3 changed files with 35 additions and 18 deletions
|
@ -217,23 +217,37 @@ public class JschFileStore extends FileStore {
|
|||
JSchConnection connection = checkConnection();
|
||||
SubMonitor subMon = SubMonitor.convert(monitor, 20);
|
||||
|
||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
|
||||
if (!subMon.isCanceled()) {
|
||||
if (!info.exists()) {
|
||||
if ((options & EFS.SHALLOW) == EFS.SHALLOW) {
|
||||
IFileStore parent = getParent();
|
||||
if (parent != null && !parent.fetchInfo(EFS.NONE, subMon.newChild(10)).exists()) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE,
|
||||
NLS.bind(Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()),
|
||||
null));
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE, NLS.bind(
|
||||
Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
|
||||
}
|
||||
if (subMon.isCanceled()) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
MkdirCommand command = new MkdirCommand(connection, fRemotePath);
|
||||
command.getResult(subMon.newChild(10));
|
||||
} else if (!info.isDirectory()) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE, NLS.bind(
|
||||
Messages.JschFileStore_The_file_of_name_already_exists, fRemotePath.toString()), null));
|
||||
} catch (Exception e) {
|
||||
// Ignore any exceptions
|
||||
}
|
||||
if (!subMon.isCanceled()) {
|
||||
/*
|
||||
* Check if the result exists and is a directory, throw an exception if neither.
|
||||
*/
|
||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
|
||||
if (!subMon.isCanceled()) {
|
||||
if (!info.exists()) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE, NLS.bind(
|
||||
Messages.JschFileStore_The_directory_could_not_be_created, fRemotePath.toString()), null));
|
||||
}
|
||||
if (!info.isDirectory()) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
|
||||
NLS.bind(Messages.JschFileStore_A_file_of_name_already_exists, fRemotePath.toString()), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@ public class Messages extends NLS {
|
|||
public static String JschFileStore_Invalid_connection_for_URI;
|
||||
public static String JschFileStore_Is_a_directory;
|
||||
public static String JschFileStore_No_remote_services_found_for_URI;
|
||||
public static String JschFileStore_The_file_of_name_already_exists;
|
||||
public static String JschFileStore_The_directory_could_not_be_created;
|
||||
|
||||
public static String JschFileStore_A_file_of_name_already_exists;
|
||||
public static String JschFileStore_The_parent_of_directory_does_not_exist;
|
||||
|
||||
static {
|
||||
|
|
|
@ -34,5 +34,6 @@ JschFileStore_File_doesnt_exist=File {0} doesn't exist
|
|||
JschFileStore_Invalid_connection_for_URI=Invalid connection for URI: "{0}"
|
||||
JschFileStore_Is_a_directory={0} is a directory
|
||||
JschFileStore_No_remote_services_found_for_URI=No remote services found for URI: "{0}"
|
||||
JschFileStore_The_file_of_name_already_exists=A file of name {0} already exists
|
||||
JschFileStore_The_directory_could_not_be_created=The directory {0} could not be created
|
||||
JschFileStore_A_file_of_name_already_exists=A file of name {0} already exists
|
||||
JschFileStore_The_parent_of_directory_does_not_exist=The parent of directory {0} does not exist
|
||||
|
|
Loading…
Add table
Reference in a new issue