Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2005-09-12 17:54:10 +0000
committerMichael Valenta2005-09-12 17:54:10 +0000
commit1e2e12870a5cfc78e8bdc7afb8a74255fc26b7d6 (patch)
tree77b9ac4b53561fdf69ff8e8bfbe6d4161db65890
parenteeb977e2bb5a64a81ae1655a8ae49434bcb05beb (diff)
downloadeclipse.platform.team-1e2e12870a5cfc78e8bdc7afb8a74255fc26b7d6.tar.gz
eclipse.platform.team-1e2e12870a5cfc78e8bdc7afb8a74255fc26b7d6.tar.xz
eclipse.platform.team-1e2e12870a5cfc78e8bdc7afb8a74255fc26b7d6.zip
Bug 109308 Make files in CVS/Base directory writable before restoring
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
index 5d9141904..1e258fd4a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
@@ -562,9 +562,7 @@ public class SyncFileWriter {
if (target.exists()) {
// XXX Should ensure that we haven't already copied it
// XXX write the revision to the CVS/Baserev file
- if (target.isReadOnly()) {
- target.setReadOnly(false);
- }
+ setReadOnly(target, false);
target.delete(true, Policy.subMonitorFor(monitor, 10));
}
// Copy the file so the timestamp is maintained
@@ -593,6 +591,8 @@ public class SyncFileWriter {
if (file.exists()) {
file.delete(false /* force */, true /* keep history */, Policy.subMonitorFor(monitor, 10));
}
+ // Make the source writtable to avoid problems on some file systems (bug 109308)
+ setReadOnly(source, false);
// Copy the file so the timestamp is maintained
source.move(file.getFullPath(), false /* force */, true /* keep history */,Policy.subMonitorFor(monitor, 100));
} catch (CoreException e) {
@@ -601,6 +601,19 @@ public class SyncFileWriter {
monitor.done();
}
}
+
+ private static void setReadOnly(IFile source, boolean readOnly) {
+ ResourceAttributes attrs = source.getResourceAttributes();
+ if (attrs.isReadOnly() != readOnly) {
+ attrs.setReadOnly(readOnly);
+ try {
+ source.setResourceAttributes(attrs);
+ } catch (CoreException e) {
+ // Just log the failure since the move may succeed anyway
+ CVSProviderPlugin.log(e);
+ }
+ }
+ }
/**
* Method deleteFileFromBaseDirectory.
@@ -614,9 +627,7 @@ public class SyncFileWriter {
IFolder baseFolder = getBaseDirectory(file);
IFile source = baseFolder.getFile(new Path(null, file.getName()));
if (source.exists()) {
- if (source.isReadOnly()) {
- source.setReadOnly(false);
- }
+ setReadOnly(source, false);
source.delete(false, false, Policy.subMonitorFor(monitor, 100));
}
} catch (CoreException e) {

Back to the top