Ticket #2361 (closed bug: obsolete)

Opened 10 years ago

Last modified 9 years ago

write-permissions -- Exception occurs when you try to save a book and don't have permissions

Reported by: deyan Owned by: stefan
Priority: major Milestone: X3
Component: uncategorized Version: 2.0
Keywords: Cc:
Category: unknown Effort:
Importance: 96 Ticket_group:
Estimated Number of Hours: 0 Add Hours to Ticket: 0
Billable?: yes Total Hours: 0
Analysis_owners: deyan Design_owners: deni, stefan
Imp._owners: deni, stefan Test_owners:
Analysis_reviewers: deni Changelog: Changelog
Design_reviewers: pap Imp._reviewers: deyan, todor, pap
Test_reviewers: Analysis_score: 4
Design_score: 3.5 Imp._score: 3.5
Test_score: 0

Description

Make a dialog that says "You don't have permissions to write in this directory". The dialog should appear when trying to save a book on a prohibited location and when closed should bring save as dialog back.

Attachments

write-permissions.patch (1.6 KB) - added by deni 10 years ago.
imr.patch (5.0 KB) - added by pap 10 years ago.
2361_de_fi.patch (2.1 KB) - added by stefan 10 years ago.
2361_de_fi.2.patch (2.2 KB) - added by stefan 10 years ago.

Change History

comment:1 Changed 10 years ago by deni

  • Status changed from new to s1b_analysis_finished

comment:2 Changed 10 years ago by deni

  • Design_owners set to deni
  • Status changed from s1b_analysis_finished to s2a_design_started
  • Imp._owners set to deni
  • Analysis_reviewers set to deni
  • Analysis_score changed from 0 to 4
  • Actually there is no exception - the save as dialog is closed and an error message that the book could not be saved appears.
  • However, I agree having a more specific error message and leaving the file dialog open, will be more convenient for the user.

Changed 10 years ago by deni

comment:3 Changed 10 years ago by deni

  • Status changed from s2a_design_started to s3b_implementation_finished
  • In FileDialog.performFileCheck(FileDialogInput, File[]) when we try to save something as file, check whether we can write in the specified directory. This can be done in the following way:
    • If file is the file we want to save the book as, then parentDir = file.getParentFile() is the directory where it is.
    • Calling parentDir.canWrite() will check whether the directory exists and whether we can write in it. This is exactly what we need.

Changed 10 years ago by pap

comment:4 Changed 10 years ago by pap

  • Status changed from s3b_implementation_finished to s1c_analysis_ok
  • Design_score changed from 0 to 2.5
  • Design_reviewers set to pap
  • Imp._score changed from 0 to 2
  • Imp._reviewers set to pap
  • Following are the experience reviewer notes. They might be a bit unclear. We made several builds with different corrections. In the attached file imr.patch you can see the code as it was when we finished the review. :
  • At first the files couldn't be saved neither in Program Files folder, nor on the desktop, however the user was able to create a new folder using the button in the file dialog and save book in it. With the latest zip the user is able to save books on the desktop, but there are some other issues listed below.
  • With the first builds the dialogs that appeared on Windows and Mac OS X differed from those that appeared on Linux.
  • On Windows and Mac OS X, there was the following bug:
    • If you try to export resource to place with no permissions, the first time a dialog message appears, but when you try to export the resource again on that place, exception is thrown.
    • The same happens if you try to overwrite a resource when it is located on place with limited access.
  • With the last zip, each time the user tries to save book or export resource, the application acted as if the book is already saved and asks the user whether he would want to overwrite it. If the user select yes, the book is saved, if the user select no, the book is saved again.
  • Implementaion remarks:
    • On windows and probably MacOS the method File.canWrite doesn't work correctly. So it is better to use a try{}catch(IOException e){} to do the check.
    • However that needs to be better synchronized with the check for file existence.
    • Also you should not only check if you can write in the parrent directory but if you can write in the file itself if it exists

comment:5 Changed 10 years ago by deyan

  • Importance set to 96

Batch update from file priorities8.csv

comment:6 Changed 10 years ago by stefan

  • Design_owners changed from deni to deni, stefan
  • Owner set to stefan
  • Status changed from s1c_analysis_ok to s2a_design_started

comment:7 Changed 10 years ago by stefan

  • Status changed from s2a_design_started to s2b_design_finished

I made only minor change of the imr.patch. Tested on win - there were no exceptions in saving book or exporting resource in not-permited folders. Design-related code:

if (inputKind.equals(FileDialogInput.Kind.SAVE)) {
			assert input.isMultiSelectEnabled() == false : "Cannot save in multiple resouces!";

			boolean writable = true;
			if (OSUtil.isWindows() || OSUtil.isMacOS()) {
				try {
					boolean created = files[0].createNewFile();
					if (created) {
						files[0].delete();
					}
				} catch (IOException e) {
					SophieLog.info("File doesn't seem writable", e);
					writable = false;
				}
			} else {
				writable = files[0].getParentFile().canWrite();
				writable = writable && (files[0].exists() && files[0].canWrite());
			}
			if (!writable) {
				DialogUtils.showErrorDialog(this.fileChooser.getParent(),
								"You don't have permissions to write in this directory.",
								"Permission denied");
				return null;
			} 

Changed 10 years ago by stefan

Changed 10 years ago by stefan

comment:8 Changed 10 years ago by stefan

  • Status changed from s2b_design_finished to s2c_design_ok

comment:9 Changed 10 years ago by stefan

  • Status changed from s2c_design_ok to s3a_implementation_started
  • Imp._owners changed from deni to deni, stefan

comment:10 Changed 10 years ago by stefan

  • Status changed from s3a_implementation_started to s3b_implementation_finished

comment:11 Changed 10 years ago by pap

  • Status changed from s3b_implementation_finished to s3c_implementation_ok
  • Design_score changed from 2.5 to 3.5
  • Imp._score changed from 2 to 3.5
  • Imp._reviewers changed from pap to deyan, todor, pap
  • Commited in [9185].
  • The flow of logic for Linux wasn't the same as for Windows/MacOS.

comment:12 Changed 9 years ago by meddle

  • Status changed from s3c_implementation_ok to closed
  • Resolution set to obsolete

Closing all the tickets before M Y1

Note: See TracTickets for help on using tickets.