Merge lp:~philip.scott/screenshot-tool/dont-overwrite into lp:~elementary-apps/screenshot-tool/trunk

Proposed by Felipe Escoto
Status: Merged
Approved by: Danielle Foré
Approved revision: 232
Merged at revision: 234
Proposed branch: lp:~philip.scott/screenshot-tool/dont-overwrite
Merge into: lp:~elementary-apps/screenshot-tool/trunk
Diff against target: 24 lines (+13/-1)
1 file modified
src/ScreenshotWindow.vala (+13/-1)
To merge this branch: bzr merge lp:~philip.scott/screenshot-tool/dont-overwrite
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+307121@code.launchpad.net

Commit message

Don't overwrite files

Description of the change

Don't overwrite files, instead append the (%d) as when you download a file

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Just one tiny code style issue ;)

232. By Felipe Escoto

Don't overwrite files

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

Works and looks good to me :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ScreenshotWindow.vala'
--- src/ScreenshotWindow.vala 2016-09-29 03:16:03 +0000
+++ src/ScreenshotWindow.vala 2016-09-30 18:16:43 +0000
@@ -320,7 +320,19 @@
320 output = output.replace (type, "");320 output = output.replace (type, "");
321 }321 }
322322
323 string file_name = Path.build_filename (folder_dir, output + "." + format);323 string file_name = "";
324 int attempt = 0;
325
326 // Check if file exists
327 do {
328 if (attempt == 0) {
329 file_name = Path.build_filename (folder_dir, "%s.%s".printf (output, format));
330 } else {
331 file_name = Path.build_filename (folder_dir, "%s (%d).%s".printf (output, attempt, format));
332 }
333
334 attempt++;
335 } while (File.new_for_path (file_name).query_exists ());
324336
325 try {337 try {
326 screenshot.save (file_name, format);338 screenshot.save (file_name, format);

Subscribers

People subscribed via source and target branches

to all changes: