Skip to content

Direct port of delete_file and delete_dir to DeleteJob - #2847

Open
jeremypw wants to merge 15 commits into
mainfrom
jeremypw/minimum-delete-port
Open

jeremypw wants to merge 15 commits into
mainfrom
jeremypw/minimum-delete-port

Conversation

@jeremypw

@jeremypw jeremypw commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Moved the delete_file and delete_dir functions from marlin_file_operations.c to Files.FileOperations.DeleteJob making minimal changes to the code structure.

  • The methods are kept as static and synchronous
  • No drying of repeated code

Some re-ordering was unavoidable because errors need to handled in try/catch clauses in Vala and cannot use goto

Later commits tidies the Vala code a little while attempting to keep logic the same or equivalent. Additional comments are added. The intention is to clarify the fairly complicated logic as far possible.

@jeremypw

Copy link
Copy Markdown
Contributor Author

@danirabbit Is this a better approach? It can be made into more elegant Vala later.

@danirabbit danirabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for breaking out this part! Much more manageable to review. Lots of things to clean up here

Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
@jeremypw

Copy link
Copy Markdown
Contributor Author

@danirabbit Thanks for the review. I didn't want to spend too much time cleaning it up until I knew I was on the right track - its just cut and pasted from C and then minimal changes to get it to compile. I'll fix up the code style now.

@jeremypw
jeremypw marked this pull request as draft September 28, 2026 18:44
@jeremypw

Copy link
Copy Markdown
Contributor Author

Converting to draft while checking changes in code not introduced behaviour changes.

@jeremypw
jeremypw marked this pull request as ready for review September 29, 2026 12:53

@danirabbit danirabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the improved comments! This looks a lot better than it did

There's some more cleanup we can do with strings here:

  • Make sure we always include the file or directory name and use typographical quotes “ ”
  • Be consistent about saying see files in “%s” or read files in “%s”
  • We also seem to have a mix of saying folder “%s” or just “%s”. I'm not sure if we need to say "folder" here unless there's some important disambiguation happening
  • If we can't provide useful secondary text, we should just use the error details instead of saying "See the details below"

Comment thread libcore/FileOperations/DeleteJob.vala Resolved
if (e is IOError.PERMISSION_DENIED) {
secondary = _("You do not have permission to read this folder.");
} else {
secondary = _("See details below for further information.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't love this. This doesn't tell us anything. Secondary text should provide information like reassurance, explain why it happened (if we can know that), provide a suggestion. If we don't have useful secondary text, we should just make the error message the secondary text imo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its hard to know what to put here that adds information (and is translatable) since we do not know what the error was. Is it OK to use an untranslated error message as secondary text?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think thats better than a message that has no real content personally

Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
Comment thread libcore/FileOperations/DeleteJob.vala Resolved
@jeremypw
jeremypw requested a review from danirabbit October 15, 2026 16:37

@danirabbit danirabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one last place with the secondary text. Otherwise this looks good to me. Thanks for addressing all that feedback!

Comment on lines +202 to +203
secondary = _("See details below for further information.");
details = e.message;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
secondary = _("See details below for further information.");
details = e.message;
secondary = e.message;

/// TRANSLATORS: %s is a placeholder for the basename of a file.
_("Could not remove the folder “%s”").printf (dir_basename),
secondary,
details,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

details is always null?

Suggested change
details,

Comment on lines +238 to +240
while (
!job.aborted () && !local_skipped_file
) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we have plenty of lines longer than this?

Suggested change
while (
!job.aborted () && !local_skipped_file
) {
while (!job.aborted () && !local_skipped_file) {

@danirabbit danirabbit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake!

Comment on lines +276 to +277
/// TRANSLATORS: %s is a placeholder for the basename of a file.
secondary = _("You do not have permissions to see files in “%s”").printf (dir_basename);

@danirabbit danirabbit Oct 15, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I'm sorry. I was wrong here. We already name the folder in the primary text, so we don't need to do it again here.

Suggested change
/// TRANSLATORS: %s is a placeholder for the basename of a file.
secondary = _("You do not have permissions to see files in “%s”").printf (dir_basename);
secondary = _("You do not have permission to see files in this folder");

string secondary;
string? details = null;
if (e is IOError.PERMISSION_DENIED) {
secondary = _("You do not have permission to read “%s”.").printf (dir_basename);

@danirabbit danirabbit Oct 15, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other. We already name the folder in the primary text, so we don't need to do it again here

Suggested change
secondary = _("You do not have permission to read “%s”.").printf (dir_basename);
secondary = _("You do not have permission to see this folder");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants