Ticket #2361 (closed bug: obsolete)

Opened 2 years ago

Last modified 2 months 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:
Ticket_group: Effort:
Category: unknown Importance: 96
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:
Design_reviewers: pap Analysis_reviewers: deni
Changelog: Changelog 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 Download (1.6 KB) - added by deni 23 months ago.
imr.patch Download (5.0 KB) - added by pap 22 months ago.
2361_de_fi.patch Download (2.1 KB) - added by stefan 21 months ago.
2361_de_fi.2.patch Download (2.2 KB) - added by stefan 21 months ago.

Change History

Changed 23 months ago by deni

  • status changed from new to s1b_analysis_finished

Changed 23 months ago by deni

  • design_owners set to deni
  • status changed from s1b_analysis_finished to s2a_design_started
  • implementation_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 23 months ago by deni

Changed 23 months 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 22 months ago by pap

Changed 22 months 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
  • implementation_score changed from 0 to 2
  • implementation_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

Changed 21 months ago by deyan

  • importance set to 96

Batch update from file priorities8.csv

Changed 21 months 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

Changed 21 months 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 21 months ago by stefan

Changed 21 months ago by stefan

Changed 21 months ago by stefan

  • status changed from s2b_design_finished to s2c_design_ok

Changed 21 months ago by stefan

  • status changed from s2c_design_ok to s3a_implementation_started
  • implementation_owners changed from deni to deni, stefan

Changed 21 months ago by stefan

  • status changed from s3a_implementation_started to s3b_implementation_finished

Changed 21 months ago by pap

  • status changed from s3b_implementation_finished to s3c_implementation_ok
  • design_score changed from 2.5 to 3.5
  • implementation_score changed from 2 to 3.5
  • implementation_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.

Changed 2 months 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.