Bug 197976 - Changing a file to read-only when it is open doesn't update local copy
Summary: Changing a file to read-only when it is open doesn't update local copy
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M3   Edit
Assignee: Kevin Doyle CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 166302 209969
  Show dependency tree
 
Reported: 2007-07-26 10:59 EDT by Kevin Doyle CLA
Modified: 2011-05-25 07:17 EDT (History)
3 users (show)

See Also:


Attachments
Changing remote file to be read-only updates local copy open in editor (7.28 KB, patch)
2007-08-29 16:53 EDT, Kevin Doyle CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2007-07-26 10:59:53 EDT
If you make a file read-only while the file is open in the editor the local copy of that file is not made read-only so you can still edit the file and try to save it then get an error.

If you do this in the Resource perspective as soon as you make a file read-only it's editor is also made read-only.

-----------Enter bugs above this line-----------
TM 2.0.1 Testing
installation : eclipse-SDK-3.3
RSE install  : Dev Driver - 
java.runtime : Sun 1.5.0_11-b03
os.name:     : Windows XP, Service Pack 2
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-07-27 12:43:30 EDT
This is related to bug #166302.

We need to avoid getting the local cached copy out-of-sync with the remote file. So when the remote is made read-only the local copy should be read-only too and vice versa.

I think one problem we had with bug 166302 was that when the local cached copy is read-only and you try saving, Eclipse asks "Do you want to make...writable?" and if you answer YES the user makes only the cached copy writable but we have no chance intercepting this and making the remote writable too. 

Or could we do that work in the Editor Save Listener? - We need to re-sync with remote already now when the user saves a file, so we could sync up the read-only-status with the remote as well at this point. Only problem might be that if remote remains read-only and we catch an error trying to set it writable, we'd need to take the proper steps.

Kevin please investigate and check if we now have the prerequisites to get bug 166302 fixed as well.
Comment 2 Kevin Doyle CLA 2007-08-29 16:53:36 EDT
Created attachment 77301 [details]
Changing remote file to be read-only updates local copy open in editor

This patch address's the issue of the local copy of a file not being updated when we make the remote file read-only and an editor is open for that file.

I also looked into the issue when we try to edit a read-only file and say Yes to wanting to make it writable.  We can't intercept or listen for read-only events it seems.  This patch also includes the changes to the synching when saving, so if the remote file is read-only when doing the synch we make the remote file writable.

Bug #3107 is open for notification of read-only changes and it's marked WONTFIX.  We could try reopening the bug and explaining our need for it.

Legal Message: I, Kevin Doyle, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 3 Kevin Doyle CLA 2007-10-19 14:31:45 EDT
Patch Applied.  Fixed in SystemEditableRemoteFile, SystemUniversalTempFileListener, and SystemFilePropertyPage.
Comment 4 Martin Oberhuber CLA 2007-10-30 20:17:43 EDT
I was considering backporting this to 2.0.x since it enables working with read-only files which I consider important, and we already have changes on the files.ui plugin for 2.0.x

When reviewing the patch, I stumbled over this piece of change in SystemEditableRemoteFile.java:

	setReadOnly(file, false);
	SystemIFileProperties properties = new SystemIFileProperties(file);
	properties.setReadOnly(true);

Why does it setReadOnly(false) first but setReadOnly(true) later?

Reopening to clarify. Also, please check if any other files than the three from the Patch would be affected for backporting.
Comment 5 Kevin Doyle CLA 2007-10-30 22:34:22 EDT
Nice catch Martin.  It should be properties.setReadOnly(false).  I've committed the change for that.

I don't see any issue's with back porting this.  To bad we didn't get to this earlier since the patch was posted at the end of August.  Would of saved on the back porting.
Comment 6 Kevin Doyle CLA 2007-11-08 10:39:43 EST
Verified fixed in I20071108.
Comment 7 Martin Oberhuber CLA 2011-05-25 07:17:36 EDT
Comment on attachment 77301 [details]
Changing remote file to be read-only updates local copy open in editor

Marking iplog+ since Kevin became a committer in oct 2007 only.