Bug 1332 - MonoDevelop can't handle read-only files correctly
Summary: MonoDevelop can't handle read-only files correctly
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: unspecified
Hardware: Macintosh Mac OS
: Low normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-10-07 03:43 UTC by Michal
Modified: 2012-10-24 16:56 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 1332 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Michal 2011-10-07 03:43:21 UTC
It looks like that OSX is using two ways how to mark file as read-only. Either „locking“ it (in Finder ctrl+left clik on file->Get Info and check Locked checkbox) or unix file system permissions. And this seems to be a problem for MonoDevelop to handle correctly, especially when performing these tasks:
 
1. Text editor: If file has only read permission, MD can detect it correctly and when saving the document it asks to save it (somwhere else or replace original file). BUT if file is „locked“, this doesnt work and all changes are lost without any word about the possible problem.

How to reproduce:
1. Create any project in MonoDevelop using template (e.g. Single View application).
2. Reveal some source code file (e.g. AppDelegate.cs) in Finder and show info about that file.
3. Check "Locked" checkbox (mark it as locked/read-only). Also make sure that file permissions (at the bottom of info dialog) are set to Read&Write
4. Return back to MonoDevelop, modify the file, save and close it.
5. Reopen the file and observe that changes are lost.

6. Return back to file's info dialog.
7. Uncheck "Locked" check box and set file's permissions to Read (only).
8. Return back to MonoDevelop, open the file, edit it and save.
9. Now MonoDevelop opens save as dialog, which is expected.


2. Building (e.g. for files, which are set as content and copy always): If file is „locked“, file is copied without this flag and during next build it can be overwritten without problems. But if file has only read permission, file is copied with its original permissions and during next build MD complains about it and build fails.

How to reproduce:
1. 1. Create any project in MonoDevelop using template (e.g. Single View application).
2. Add any file to the project, set is as Content and Copy always.
3. Reveal that file in Finder and show info about that file
4. Check "Locked" checkbox (mark it as locked/read-only). Also make sure that file permissions (at the bottom of info dialog) are set to Read&Write
5. Return back to MonoDevelop and build the project. Then rebuild the project again (or try to clean it).
6. Observe no problems. You can also check in the output bin/ folder that file's "Locked" check was not preserved and is missing.

7. Return back to file's info dialog.
8. Uncheck "Locked" check box and set file's permissions to Read (only).
9. Return back to MonoDevelop, build project and then rebuild it again (or try to clean it).
10. Now MonoDevelop complains about problems with deleting file(s) because of permissions.

The same applies to latest versions of all main MonoDevelop versions (2.4.x, 2.6.x, 2.8).
Comment 1 Mike Krüger 2012-04-20 03:37:21 UTC
IMO the best solution would be to fix that in mono.

File.GetAttributes (fileName) should return the FileAttributes.ReadOnly in that case. This would have much benefit for all mono based applications.