mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
[199548] Avoid touching files on setReadOnly() if unnecessary
This commit is contained in:
parent
768f2cb6a0
commit
c7b06ec1e7
1 changed files with 11 additions and 11 deletions
|
@ -56,6 +56,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [198638] Fix invalid caching
|
* Martin Oberhuber (Wind River) - [198638] Fix invalid caching
|
||||||
* Martin Oberhuber (Wind River) - [198645] Fix case sensitivity issues
|
* Martin Oberhuber (Wind River) - [198645] Fix case sensitivity issues
|
||||||
* Martin Oberhuber (Wind River) - [192610] Fix thread safety for delete(), upload(), setReadOnly() operations
|
* Martin Oberhuber (Wind River) - [192610] Fix thread safety for delete(), upload(), setReadOnly() operations
|
||||||
|
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.files.ftp;
|
package org.eclipse.rse.internal.services.files.ftp;
|
||||||
|
@ -1260,29 +1261,28 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException {
|
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException {
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
int permissions = 0;
|
|
||||||
|
|
||||||
FTPHostFile file = getFileInternal(parent,name, monitor);
|
FTPHostFile file = getFileInternal(parent,name, monitor);
|
||||||
|
|
||||||
int userPermissions = file.getUserPermissions();
|
int userPermissions = file.getUserPermissions();
|
||||||
int groupPermissions = file.getGroupPermissions();
|
int groupPermissions = file.getGroupPermissions();
|
||||||
int otherPermissions = file.getOtherPermissions();
|
int otherPermissions = file.getOtherPermissions();
|
||||||
|
|
||||||
if(readOnly)
|
int oldPermissions = userPermissions * 100 + groupPermissions * 10 + otherPermissions;
|
||||||
{
|
if(readOnly) {
|
||||||
userPermissions &= 5; // & 101b
|
userPermissions &= 5; // & 101b
|
||||||
}
|
groupPermissions &= 5; // & 101b
|
||||||
else
|
otherPermissions &= 5; // & 101b
|
||||||
{
|
} else {
|
||||||
userPermissions |= 2; // | 010b
|
userPermissions |= 2; // | 010b
|
||||||
}
|
}
|
||||||
|
int newPermissions = userPermissions * 100 + groupPermissions * 10 + otherPermissions;
|
||||||
permissions = userPermissions * 100 + groupPermissions * 10 + otherPermissions;
|
|
||||||
|
|
||||||
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) {
|
if (newPermissions==oldPermissions) {
|
||||||
|
result = true;
|
||||||
|
} else if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) {
|
||||||
try {
|
try {
|
||||||
clearCache(parent);
|
clearCache(parent);
|
||||||
result =_ftpClient.sendSiteCommand("CHMOD "+permissions+" "+file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
|
result =_ftpClient.sendSiteCommand("CHMOD "+newPermissions+" "+file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
result = false;
|
result = false;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Add table
Reference in a new issue