After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 619014 - CopyRecursive needs cleaning up
CopyRecursive needs cleaning up
Status: RESOLVED WONTFIX
Product: f-spot
Classification: Other
Component: General
GIT
Other Linux
: High normal
: ---
Assigned To: Paul Wellner Bou
F-spot maintainers
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2010-05-18 18:33 UTC by Ruben Vermeersch
Modified: 2018-07-01 08:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoid use of exceptions, fix directory type comparison (3.24 KB, patch)
2010-05-19 07:55 UTC, Paul Wellner Bou
committed Details | Review
Fix critical GLib warning regarding canncellable (1.07 KB, patch)
2010-05-19 07:55 UTC, Paul Wellner Bou
committed Details | Review
Fix critical GLib warning regarding canncellable (1.07 KB, patch)
2010-05-19 08:59 UTC, Ruben Vermeersch
committed Details | Review
Avoid use of exceptions, fix directory type comparison (3.24 KB, patch)
2010-05-19 08:59 UTC, Ruben Vermeersch
committed Details | Review
Use CopyRecursive as extension method (1.09 KB, patch)
2010-05-19 09:26 UTC, Paul Wellner Bou
committed Details | Review
More cleanups and clearer dialog messages (3.11 KB, patch)
2010-05-19 11:34 UTC, Paul Wellner Bou
needs-work Details | Review
No need to check result as if result is false, an exception will be thrown before. (1.79 KB, patch)
2010-05-19 11:34 UTC, Paul Wellner Bou
accepted-commit_now Details | Review
More cleanup, use Log.Debug and consistent dialog messages (3.83 KB, patch)
2010-05-19 11:34 UTC, Paul Wellner Bou
accepted-commit_now Details | Review
Don't mark debug output as translatable, logging errors to Log.Error (3.08 KB, patch)
2010-05-19 11:57 UTC, Paul Wellner Bou
none Details | Review
Cleanup, consistent debug and dialog messages, debug/error output (7.31 KB, patch)
2010-05-19 13:44 UTC, Paul Wellner Bou
none Details | Review
dialog messages and clean up (3.57 KB, patch)
2010-05-19 14:17 UTC, Paul Wellner Bou
committed Details | Review
No need to check result as if result is false, an exception will be thrown before. (1.81 KB, patch)
2010-05-19 14:18 UTC, Paul Wellner Bou
committed Details | Review
Cleanup, consistent debug and dialog messages, debug/error output (7.31 KB, patch)
2010-05-19 14:18 UTC, Paul Wellner Bou
committed Details | Review

Description Ruben Vermeersch 2010-05-18 18:33:48 UTC
CopyRecursive needs improving:

* Exceptions are only meant as an exceptional failure notifier (they have horrible performance). So the answer to the TODO is: check for directory.

* I get critical GIO warnings (just enabled stack dumping of them)

* Progress reporting is probably wrong, but I'm not sure if you can easily improve on it, except for walking the whole tree first (that would be the right solution, walk the tree and count the number of files, then walk again and copy them).

* Log.Debug (String.Format (Catalog.GetString("Copying {0} -> {1}"), source_file.Path, target_file.Path)); this can be: Log.Debug (Catalog.GetString("Copying {0} -> {1}"), source_file.Path, target_file.Path); Log.Debug supports parameters.
Comment 1 Paul Wellner Bou 2010-05-19 07:55:03 UTC
Created attachment 161412 [details] [review]
Avoid use of exceptions, fix directory type comparison
Comment 2 Paul Wellner Bou 2010-05-19 07:55:12 UTC
Created attachment 161413 [details] [review]
Fix critical GLib warning regarding canncellable
Comment 3 Paul Wellner Bou 2010-05-19 07:57:22 UTC
Progress reporting (and the correct use of cancellable) should be fixed in FolderExport.
Comment 4 Ruben Vermeersch 2010-05-19 08:59:43 UTC
The following fixes have been pushed:
53bf478 Fix critical GLib warning regarding canncellable
57f4a55 Avoid use of exceptions, fix directory type comparison

Thanks for cleaning this up! One last notice: you can use extension methods as
member methods instead of static methods. So instead of:

    CopyRecursivei (source_file, target_file ...)

You can write:

    source_file.CopyRecursive (target_file ...)

Which is a bit nicer on the eye :-).
Comment 5 Ruben Vermeersch 2010-05-19 08:59:46 UTC
Created attachment 161415 [details] [review]
Fix critical GLib warning regarding canncellable
Comment 6 Ruben Vermeersch 2010-05-19 08:59:48 UTC
Created attachment 161416 [details] [review]
Avoid use of exceptions, fix directory type comparison
Comment 7 Ruben Vermeersch 2010-05-19 09:00:57 UTC
Okay that didn't work out as planned, for some reason git-bz added new patches instead of marking the old ones as committed. Sorry for the noise!
Comment 8 Ruben Vermeersch 2010-05-19 09:12:54 UTC
Reopening, progress reporting isn't right yet, we need something smarter. It currently reports progress for files, but that means we get non-monotonic reporting:

Suppose we have two files A and B. It would report something like:

(A) 33%
(A) 66%
(A) 100%
(B) 33%
(B) 66%
(B) 100%

What we really want is:

(Starting) 0%
(A done)   50%
(B done)   100%

That would require walking the directory first :-)

========================================================

Also, cancellable doesn't really work correctly: if I use the supplied cancellable to abort the copy, it won't really stop copying, it'll just abort some of the operations but still walk through the entire tree.

It's probably better if you pass each of the suboperations a null cancellable and check the status of the cancellable inside CopyRecursive, breaking out of the loop / methods when cancelled. This is what I think causes the GIO errors, passing null should be allowed.
Comment 9 Paul Wellner Bou 2010-05-19 09:26:12 UTC
Created attachment 161419 [details] [review]
Use CopyRecursive as extension method
Comment 10 Ruben Vermeersch 2010-05-19 09:31:56 UTC
Comment on attachment 161419 [details] [review]
Use CopyRecursive as extension method

Attachment 161419 [details] pushed as a46f010 - Use CopyRecursive as extension method
Comment 11 Paul Wellner Bou 2010-05-19 09:41:27 UTC
I passed null as cancellable before, in the first call of CopyRecursive in
FolderExport.cs. So null seems to cause the GLib warnings.

But you're right, I should check if cancellable was cancelled and about the
walk through the tree. (But then we should add a Cancel button to the
ThreadProgressDialog.)

To cancel it, may be we should use CopyAsync?
Comment 12 Paul Wellner Bou 2010-05-19 11:34:06 UTC
Created attachment 161425 [details] [review]
More cleanups and clearer dialog messages
Comment 13 Paul Wellner Bou 2010-05-19 11:34:15 UTC
Created attachment 161426 [details] [review]
No need to check result as if result is false, an exception will be thrown before.
Comment 14 Paul Wellner Bou 2010-05-19 11:34:24 UTC
Created attachment 161427 [details] [review]
More cleanup, use Log.Debug and consistent dialog messages
Comment 15 Ruben Vermeersch 2010-05-19 11:45:44 UTC
Review of attachment 161425 [details] [review]:

Looks good, but please don't mark debug messages as translatable. They're not user visible anyway (and I don't want to be debugging chinese messages ;-)). We don't want to give our translators more work than needed.
Comment 16 Ruben Vermeersch 2010-05-19 11:46:54 UTC
Review of attachment 161426 [details] [review]:

Looks good.
Comment 17 Ruben Vermeersch 2010-05-19 11:47:07 UTC
Review of attachment 161427 [details] [review]:

Looks good
Comment 18 Paul Wellner Bou 2010-05-19 11:57:53 UTC
Created attachment 161428 [details] [review]
Don't mark debug output as translatable, logging errors to Log.Error
Comment 19 Paul Wellner Bou 2010-05-19 13:44:22 UTC
Created attachment 161436 [details] [review]
Cleanup, consistent debug and dialog messages, debug/error output
Comment 20 Paul Wellner Bou 2010-05-19 14:17:19 UTC
Created attachment 161445 [details] [review]
dialog messages and clean up
Comment 21 Paul Wellner Bou 2010-05-19 14:18:03 UTC
Created attachment 161446 [details] [review]
No need to check result as if result is false, an exception will be thrown before.
Comment 22 Paul Wellner Bou 2010-05-19 14:18:21 UTC
Created attachment 161447 [details] [review]
Cleanup, consistent debug and dialog messages, debug/error output
Comment 23 Ruben Vermeersch 2010-05-19 14:24:56 UTC
Attachment 161445 [details] pushed as 9e9edec - dialog messages and clean up
Attachment 161446 [details] pushed as 7fb4980 - No need to check result as if result is false, an exception will be thrown before.
Attachment 161447 [details] pushed as 7e2d3c5 - Cleanup, consistent debug and dialog messages, debug/error output

Thanks!
Comment 24 André Klapper 2018-07-01 08:55:48 UTC
f-spot is not under active development anymore, has not seen code changes for five years, and saw its last tarball release in the year 2010.
Its codebase has been archived: https://gitlab.gnome.org/Archive/f-spot/commits/master

Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Please feel free to reopen this ticket (or rather transfer the project to GNOME Gitlab, as GNOME Bugzilla is deprecated) if anyone takes the responsibility for active development again.