Describe the bug
As reported by @kswang1029 and described in carta-backend #1377:
If we save an image without giving a filename in the file browser dialog and click the save button, there will be an error toast showing the target saving directory not found. But then the original target directory is actually gone. This is a critical bug as user data will be lost.
We can also currently overwrite any directory, file, or image by typing in the path as the name of the file to save. The backend overwrites the path in the SaveFile message unless it is the source image path, assuming the frontend has confirmed the overwrite with the "overwrite?" dialog. The frontend only shows this dialog when the path is an image in the current file list.
To Reproduce
TEST WITH CAUTION!
Steps to reproduce the behavior:
create a test directory call "test_save_image" somewhere in the directory tree (eg ~/carta_image_pool/test_save_image)
load an image
use the save image dialog to save it with a filename in ~/carta_image_pool/test_save_image. This should be successful and we do see a new file is created in the target directory.
now use the save image dialog to save it once again but with giving a filename (ie empty filename). Then we will see an error toast and if we check the existence of ~/carta_image_pool/test_save_image, it is gone!
type in the name of a directory in the current file list. The directory is overwritten with the image!
Expected behavior
We should apply these fixes:
If the target filename is blank, disable the save button
When the user confirms the image overwrite, set new SaveFile overwrite field to true. protobuf PR #97 (branch: save_file_overwrite).
In the backend, SaveFile fails when:
filename is blank: message = "Cannot save image with no filename."
filename is source image: message = "Cannot overwrite the source image."
filename is non-image directory: message = "Cannot overwrite existing directory."
These are error conditions where the image will not be saved, regardless of the overwrite flag. Show error message to user.
filename is image and overwrite=false: message = "Cannot overwrite existing image."
In this case, frontend did not detect that the path is an image (or user bypassed the frontend with scripting), so we need user confirmation to overwrite. Frontend should pop up dialog, if ok then send SaveFile with overwrite=true.
Describe the bug As reported by @kswang1029 and described in carta-backend #1377:
If we save an image without giving a filename in the file browser dialog and click the save button, there will be an error toast showing the target saving directory not found. But then the original target directory is actually gone. This is a critical bug as user data will be lost.
We can also currently overwrite any directory, file, or image by typing in the path as the name of the file to save. The backend overwrites the path in the SaveFile message unless it is the source image path, assuming the frontend has confirmed the overwrite with the "overwrite?" dialog. The frontend only shows this dialog when the path is an image in the current file list.
To Reproduce TEST WITH CAUTION!
Steps to reproduce the behavior:
Expected behavior We should apply these fixes:
overwrite
field to true. protobuf PR #97 (branch: save_file_overwrite).In the backend, SaveFile fails when:
These are error conditions where the image will not be saved, regardless of the overwrite flag. Show error message to user.
In this case, frontend did not detect that the path is an image (or user bypassed the frontend with scripting), so we need user confirmation to overwrite. Frontend should pop up dialog, if ok then send SaveFile with
overwrite
=true.Backend PR #1378 (branch: pam/1377_save_image)
This fix should also be backported to the last release.
Platform info (please complete the following information):