Merge lp:~evfool/pantheon-photos/lp1341812 into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Robert Roth
Status: Merged
Approved by: Robert Roth
Approved revision: 2554
Merged at revision: 2569
Proposed branch: lp:~evfool/pantheon-photos/lp1341812
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 99 lines (+24/-22)
4 files modified
src/Dialogs.vala (+21/-19)
src/PhotoPage.vala (+1/-1)
src/library/LibraryWindow.vala (+1/-1)
src/library/TrashPage.vala (+1/-1)
To merge this branch: bzr merge lp:~evfool/pantheon-photos/lp1341812
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Tom Beckmann (community) code (not actually tested) Approve
xapantu (community) Needs Fixing
Review via email: mp+226945@code.launchpad.net

Commit message

Only delete files when emptying the Trash, in other cases (e.g. Remove from library) do not delete the files to avoid data loss.

Description of the change

Only delete files when emptying the Trash, in other cases (e.g. Remove from library) do not delete the files to avoid data loss.

To post a comment you must log in.
Revision history for this message
Corentin Noël (tintou) wrote :

It's nice, I've made some comments to improve Photos

Revision history for this message
xapantu (xapantu) wrote :

After some discussion:
1. Put to trash should put the file into the real system trash
2. The trash view should show the images from the system trash (and maybe even only the ones that were in ~/Image before their deletion).

review: Needs Fixing
Revision history for this message
Tom Beckmann (tombeckmann) wrote :

It looks like the original idea for trashing in shotwell was very non-destructive. They don't even move an original file after it was trashed to some special place, but only flag the file as deleted in their database. So apparently they were aiming to keep the original file structure intact and limiting themselves to changes on their database. I haven't read much of the code yet, but my impression is that there's a vast number of different subclasses handling trashing differently or relying on some state of the files. My guess would be that it's relatively difficult to rework this structure, just because of the number of places where you have to make sure that the file is not accessed at its original spot, but I don't know if evfool already made progress on that? Maybe I missed something obvious. Otherwise I'd suggest to keep shortwell's non-destructive trashing system and go with the changes proposed by evfool so far.

Revision history for this message
Robert Roth (evfool) wrote :

@Tom: no, I haven't had the time to look into this yet, so I don't know how complicated it would be. Theoretically yes, several subclasses are overriding the same superclass method for "trashing files", but as far as I saw this so far, it shouldn't be that complicated to implement what xapantu suggests (to only show the images from trash that have been managed by photos exactly because they have an internal reference in -photos' database)

I will take a look at this and will check back with the results sometime this week.

Revision history for this message
Robert Roth (evfool) wrote :

This seems to be harder than I first thought: as there seems to be no way to find out the URL of a file in the trash (after trashing), thus restoring is not trivial. Will look into other ways (e.g. iterating through the files in the trash to see which ones appear in Photos' database)

Revision history for this message
Jacob Parker (jacobparker1992) wrote :
Revision history for this message
Danielle Foré (danrabbit) wrote :

It sounds like what Lucas is referring to is outside the scope of this particular merge. A separate merge should be made that addresses the bug that Jacob linked. This merge should only deal with correcting the data loss associated with the current "Remove from Library" menu item.

Revision history for this message
Tom Beckmann (tombeckmann) wrote :

Code looks great!!

review: Approve (code (not actually tested))
Revision history for this message
David Gomes (davidgomes) wrote :

Works.

review: Approve
Revision history for this message
RabbitBot (rabbitbot-a) wrote :

Attempt to merge into lp:pantheon-photos failed due to conflicts:

text conflict in src/Dialogs.vala
text conflict in src/PhotoPage.vala
text conflict in src/library/LibraryWindow.vala
text conflict in src/library/TrashPage.vala

lp:~evfool/pantheon-photos/lp1341812 updated
2553. By Robert Roth

Merged from trunk

2554. By Robert Roth

Coding style fixes for styling broken at merge

Revision history for this message
Robert Roth (evfool) wrote :

Merged from trunk, reapproving.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Dialogs.vala'
2--- src/Dialogs.vala 2014-08-08 21:13:09 +0000
3+++ src/Dialogs.vala 2014-08-09 14:07:50 +0000
4@@ -2658,11 +2658,11 @@
5
6 public void remove_photos_from_library (Gee.Collection<LibraryPhoto> photos) {
7 remove_from_app (photos, _ ("Remove From Library"),
8- (photos.size == 1) ? _ ("Removing Photo From Library") : _ ("Removing Photos From Library"));
9+ (photos.size == 1) ? _ ("Removing Photo From Library") : _ ("Removing Photos From Library"), false);
10 }
11
12 public void remove_from_app (Gee.Collection<MediaSource> sources, string dialog_title,
13- string progress_dialog_text) {
14+ string progress_dialog_text, bool delete_files) {
15 if (sources.size == 0)
16 return;
17
18@@ -2680,23 +2680,25 @@
19 }
20
21 // Remove and attempt to trash.
22- LibraryPhoto.global.remove_from_app (photos, true, monitor, null);
23- Video.global.remove_from_app (videos, true, monitor, null);
24-
25- // Attempt to delete the files.
26- Gee.ArrayList<LibraryPhoto> not_deleted_photos = new Gee.ArrayList<LibraryPhoto> ();
27- Gee.ArrayList<Video> not_deleted_videos = new Gee.ArrayList<Video> ();
28- LibraryPhoto.global.delete_backing_files (photos, monitor, not_deleted_photos);
29- Video.global.delete_backing_files (videos, monitor, not_deleted_videos);
30-
31- int num_not_deleted = not_deleted_photos.size + not_deleted_videos.size;
32- if (num_not_deleted > 0) {
33- // Alert the user that the files were not removed.
34- string delete_failed_message =
35- ngettext ("The photo or video cannot be deleted.",
36- "%d photos/videos cannot be deleted.",
37- num_not_deleted).printf (num_not_deleted);
38- AppWindow.error_message_with_title (dialog_title, delete_failed_message, AppWindow.get_instance ());
39+ LibraryPhoto.global.remove_from_app (photos, delete_files, monitor, null);
40+ Video.global.remove_from_app (videos, delete_files, monitor, null);
41+
42+ if (delete_files) {
43+ // Attempt to delete the files.
44+ Gee.ArrayList<LibraryPhoto> not_deleted_photos = new Gee.ArrayList<LibraryPhoto> ();
45+ Gee.ArrayList<Video> not_deleted_videos = new Gee.ArrayList<Video> ();
46+ LibraryPhoto.global.delete_backing_files (photos, monitor, not_deleted_photos);
47+ Video.global.delete_backing_files (videos, monitor, not_deleted_videos);
48+
49+ int num_not_deleted = not_deleted_photos.size + not_deleted_videos.size;
50+ if (num_not_deleted > 0) {
51+ // Alert the user that the files were not removed.
52+ string delete_failed_message =
53+ ngettext ("The photo or video cannot be deleted.",
54+ "%d photos/videos cannot be deleted.",
55+ num_not_deleted).printf (num_not_deleted);
56+ AppWindow.error_message_with_title (dialog_title, delete_failed_message, AppWindow.get_instance ());
57+ }
58 }
59
60 if (progress != null)
61
62=== modified file 'src/PhotoPage.vala'
63--- src/PhotoPage.vala 2014-08-08 21:13:09 +0000
64+++ src/PhotoPage.vala 2014-08-09 14:07:50 +0000
65@@ -3117,7 +3117,7 @@
66 Gee.Collection<LibraryPhoto> photos = new Gee.ArrayList<LibraryPhoto> ();
67 photos.add (photo);
68
69- remove_from_app (photos, _ ("Remove From Library"), _ ("Removing Photo From Library"));
70+ remove_from_app (photos, _ ("Remove From Library"), _ ("Removing Photo From Library"), false);
71 }
72
73 private void on_move_to_trash () {
74
75=== modified file 'src/library/LibraryWindow.vala'
76--- src/library/LibraryWindow.vala 2014-08-08 21:13:09 +0000
77+++ src/library/LibraryWindow.vala 2014-08-09 14:07:50 +0000
78@@ -737,7 +737,7 @@
79 to_remove.add_all (LibraryPhoto.global.get_trashcan_contents ());
80 to_remove.add_all (Video.global.get_trashcan_contents ());
81
82- remove_from_app (to_remove, _ ("Empty Trash"), _ ("Emptying Trash..."));
83+ remove_from_app (to_remove, _ ("Empty Trash"), _ ("Emptying Trash..."), true);
84
85 AppWindow.get_command_manager ().reset ();
86 }
87
88=== modified file 'src/library/TrashPage.vala'
89--- src/library/TrashPage.vala 2014-08-08 21:13:09 +0000
90+++ src/library/TrashPage.vala 2014-08-09 14:07:50 +0000
91@@ -113,7 +113,7 @@
92
93 private void on_delete () {
94 remove_from_app ((Gee.Collection<MediaSource>) get_view ().get_selected_sources (), _ ("Delete"),
95- (get_view ().get_selected_count () == 1) ? ("Deleting a Photo") : _ ("Deleting Photos"));
96+ ngettext("Deleting a Photo", "Deleting Photos", get_view().get_selected_count()), true);
97 }
98
99 public override SearchViewFilter get_search_view_filter () {

Subscribers

People subscribed via source and target branches

to all changes: