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 775253 - Ask whether to unpack when archive could file up disk
Ask whether to unpack when archive could file up disk
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: File and Folder Operations
3.22.x
Other Linux
: Normal normal
: future
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-11-28 16:10 UTC by Bastien Nocera
Modified: 2017-03-29 15:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
extraction: check filespace before extraction (3.23 KB, patch)
2017-03-13 17:29 UTC, Vyas Giridhar
none Details | Review
Forced error. (14.90 KB, image/png)
2017-03-23 02:02 UTC, Vyas Giridhar
  Details
extraction: check filespace before extraction (3.27 KB, patch)
2017-03-23 15:05 UTC, Vyas Giridhar
needs-work Details | Review
file-operations: check filespace before extracting (3.08 KB, patch)
2017-03-28 01:41 UTC, Vyas Giridhar
committed Details | Review

Description Bastien Nocera 2016-11-28 16:10:44 UTC
I'm not sure what the heuristics should be, but we should probably avoid unpacking huge archives on double-click, or middling-size archives if disk space is low.

For example, unpacking a 2 or 4 GB .tar.gz that contains a game when I only have slightly above that amount in disk space. This would also avoid having the housekeeping plugin popping up a notification during unpacking.
Comment 1 Ondrej Holy 2016-11-29 09:34:20 UTC
GVfs provides archive backend (which is a little bit forgotten), which is based on libarchive, same as the built-in solution in Nautilus (so it has same features). The backend is quite fast because it reads just headers to show the files. So, the archive content might be shown using the backend on double-click (it doesn't need any additional space) instead of extracting and button might be shown on the top in order to allow extracting the archive... What do you think?
Comment 2 Bastien Nocera 2016-11-29 09:40:07 UTC
(In reply to Ondrej Holy from comment #1)
> GVfs provides archive backend (which is a little bit forgotten), which is
> based on libarchive, same as the built-in solution in Nautilus (so it has
> same features). The backend is quite fast because it reads just headers to
> show the files. So, the archive content might be shown using the backend on
> double-click (it doesn't need any additional space) instead of extracting
> and button might be shown on the top in order to allow extracting the
> archive... What do you think?

This isn't about changing the current interface, but rather about avoiding the worst case scenarios.
Comment 3 Carlos Soriano 2016-11-29 09:42:16 UTC
(In reply to Ondrej Holy from comment #1)
> GVfs provides archive backend (which is a little bit forgotten), which is
> based on libarchive, same as the built-in solution in Nautilus (so it has
> same features). The backend is quite fast because it reads just headers to
> show the files. So, the archive content might be shown using the backend on
> double-click (it doesn't need any additional space) instead of extracting
> and button might be shown on the top in order to allow extracting the
> archive... What do you think?

That's the opposite of what we want I think, that's the main reason why gnome-autoar exists in the first place.

But it's something I pondered (I think we discussed between us too right?) and worth asking designers.

But yeah this bug report is not about that, but rather avoid when something bad is going to happen.
Comment 4 Vyas Giridhar 2017-03-13 17:29:56 UTC
Created attachment 347855 [details] [review]
extraction: check filespace before extraction

Sometimes, the extractions starts without enough filesystem
space to store the extracted files.
This commit checks for filespace before the extraction takes place.
Comment 5 Carlos Soriano 2017-03-22 17:01:33 UTC
Review of attachment 347855 [details] [review]:

Hey! good work, the code looks nice. However it cannot ever work I think, did you try it?

Also some nitpicks

::: src/nautilus-file-operations.c
@@ +8401,3 @@
+    basename = get_basename (source_file);
+
+    g_autofree gchar *basename = NULL;

Here you are unconditionally setting the error. Is that what you wanted?

@@ +8412,3 @@
+
+    if (total_size > g_file_info_get_attribute_uint64 (fsinfo,
+    source_file = autoar_extractor_get_source_file (extractor);

can you put this in a variable?

@@ +8414,3 @@
+                                                       G_FILE_ATTRIBUTE_FILESYSTEM_FREE) && total_size != -1)
+    {
+    basename = get_basename (source_file);

UI has to be ran in the main thread, this should actually not work. Did you test the patch?

@@ +8424,3 @@
+      if (response_id == 0 || response_id == GTK_RESPONSE_DELETE_EVENT)
+      {
+

4 spaces
Comment 6 Vyas Giridhar 2017-03-23 02:02:39 UTC
Created attachment 348548 [details]
Forced error.

It works for me when I force an error.

run_error -> run_simple_dialog_va -> g_main_context_invoke which runs the dialog in the UI thread.

updating the changes :)
Comment 7 Piotr Drąg 2017-03-23 03:45:12 UTC
I would suggest changing the error string to something more natural sounding, for example:

"Not enough free space to extract “%s”."
Comment 8 Vyas Giridhar 2017-03-23 15:05:51 UTC
Created attachment 348577 [details] [review]
extraction: check filespace before extraction

Sometimes, the extractions starts without enough filesystem
space to store the extracted files.
This commit checks for filespace before the extraction takes place.
Comment 9 Carlos Soriano 2017-03-27 19:38:10 UTC
Review of attachment 348577 [details] [review]:

The commit message tittle is missing the correct file that you modified.
The commit message is also missing some context, also it says "sometimes" but not sure in what cases, you can explain that context a little more.

::: src/nautilus-file-operations.c
@@ +8410,3 @@
+                                                  G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+
+    extract_job = user_data;

does the second condition makes sense at all? when can -1 be bigger than free_size?

Also, when total_size can be -1?
I can see in autoar:
  /* If we are unable to determine the total size, set it to a positive
   * number to prevent strange percentage. */
  if (self->total_size <= 0)
    self->total_size = G_MAXUINT64;

Which is IMHO wrong anyway. We should have an API for querying whether the size can be determined or not. For the time being anyway, but can just assume the number is positive.

@@ +8423,3 @@
+                               NULL);
+
+                                           G_FILE_ATTRIBUTE_FILESYSTEM_FREE ","

what is 0? Use constants like you do in the other one. Also, does it make sense to have this conditional at all? In what case we wouldn't abort the job?
Comment 10 Vyas Giridhar 2017-03-28 01:35:20 UTC
(In reply to Carlos Soriano from comment #9)
> Review of attachment 348577 [details] [review] [review]:
> 
> The commit message tittle is missing the correct file that you modified.
> The commit message is also missing some context, also it says "sometimes"
> but not sure in what cases, you can explain that context a little more.
> 
> ::: src/nautilus-file-operations.c
> @@ +8410,3 @@
> +                                                 
> G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
> +
> +    extract_job = user_data;
> 
> does the second condition makes sense at all? when can -1 be bigger than
> free_size?
> 
> Also, when total_size can be -1?
> I can see in autoar:
>   /* If we are unable to determine the total size, set it to a positive
>    * number to prevent strange percentage. */
>   if (self->total_size <= 0)
>     self->total_size = G_MAXUINT64;
> 
> Which is IMHO wrong anyway. We should have an API for querying whether the
> size can be determined or not. For the time being anyway, but can just
> assume the number is positive.
> 

total_size is an uint64. So, int -1 = 18,446,744,073,709,551,615 uint64

it will for most cases be more than the available space.

Hence my usage of the -1.

> @@ +8423,3 @@
> +                               NULL);
> +
> +                                           G_FILE_ATTRIBUTE_FILESYSTEM_FREE
> ","
> 
> what is 0? Use constants like you do in the other one. Also, does it make
> sense to have this conditional at all? In what case we wouldn't abort the
> job?

Removing the conditional statement. :)
Comment 11 Vyas Giridhar 2017-03-28 01:41:12 UTC
Created attachment 348850 [details] [review]
file-operations: check filespace before extracting

Currently, the extraction starts without checking
for enough filesystem space to store the extracted files.

This commit checks for filespace before the extraction takes place.
Comment 12 Carlos Soriano 2017-03-28 10:36:09 UTC
> 
> total_size is an uint64. So, int -1 = 18,446,744,073,709,551,615 uint64
> 
> it will for most cases be more than the available space.
> 
> Hence my usage of the -1.
> 
ugh, that's quite bad... also I'm not sure this is really well defined in the standard (looking http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf ) so it could even be implementation dependent.
Comment 13 Carlos Soriano 2017-03-28 10:38:10 UTC
Review of attachment 348850 [details] [review]:

The commit message looks a little small for such a change, and a comment explaining the G_MAXUINT64 would be needed since nowhere in that code is obvious or explained why this value, but I can add that. Otherwise looks good to me!
Comment 14 Ernestas Kulik 2017-03-28 10:45:11 UTC
(In reply to Carlos Soriano from comment #12)
> > 
> > total_size is an uint64. So, int -1 = 18,446,744,073,709,551,615 uint64
> > 
> > it will for most cases be more than the available space.
> > 
> > Hence my usage of the -1.
> > 
> ugh, that's quite bad... also I'm not sure this is really well defined in
> the standard (looking
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf ) so it could even
> be implementation dependent.

No, it’s well-defined. The signed operand of lower or equal rank is converted to the unsigned type of the greater rank, but I’m fairly sure that compilers complain about such implicit conversions with the right flags. There are other ways to get the maximum value.
Comment 15 Carlos Soriano 2017-03-28 10:48:37 UTC
Review of attachment 348850 [details] [review]:

::: src/nautilus-file-operations.c
@@ +8404,3 @@
+                                           G_FILE_ATTRIBUTE_FILESYSTEM_FREE ","
+                                           G_FILE_ATTRIBUTE_FILESYSTEM_READONLY,
+    guint64 free_size;

This is wrong too, you should see a warning on the compiler, you are passing a pointer to a pointer, this will make it crash if something tries to modify it.
Comment 16 Michael Catanzaro 2017-03-28 10:49:29 UTC
(In reply to Ernestas Kulik from comment #14)
> No, it’s well-defined. The signed operand of lower or equal rank is
> converted to the unsigned type of the greater rank, but I’m fairly sure that
> compilers complain about such implicit conversions with the right flags.
> There are other ways to get the maximum value.

Yeah, it's fine: http://stackoverflow.com/questions/7221409/is-unsigned-integer-subtraction-defined-behavior

But that doesn't make it a good idea. This is what G_MAXUINT64 is for. Or UINT64_MAX from stdint.h....
Comment 17 Carlos Soriano 2017-03-28 10:53:31 UTC
Attachment 348850 [details] pushed as f30a589 - file-operations: check filespace before extracting
Comment 18 Carlos Soriano 2017-03-28 18:54:46 UTC
(In reply to Ernestas Kulik from comment #14)
> (In reply to Carlos Soriano from comment #12)
> > > 
> > > total_size is an uint64. So, int -1 = 18,446,744,073,709,551,615 uint64
> > > 
> > > it will for most cases be more than the available space.
> > > 
> > > Hence my usage of the -1.
> > > 
> > ugh, that's quite bad... also I'm not sure this is really well defined in
> > the standard (looking
> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf ) so it could even
> > be implementation dependent.
> 
> No, it’s well-defined. The signed operand of lower or equal rank is
> converted to the unsigned type of the greater rank, but I’m fairly sure that
> compilers complain about such implicit conversions with the right flags.
> There are other ways to get the maximum value.

I was more talking about -1 being exactly G_MAXUINT64 (like the link Michael pointed to), it's not clear to me that from that sentence in the standard means how it converts it, and that can be implementation dependent no? (or I do not understand completely that sentence of the standard).
Comment 19 Ernestas Kulik 2017-03-28 19:34:37 UTC
(In reply to Carlos Soriano from comment #18)
> I was more talking about -1 being exactly G_MAXUINT64 (like the link Michael
> pointed to)

I know.

> it's not clear to me that from that sentence in the standard
> means how it converts it, and that can be implementation dependent no? (or I
> do not understand completely that sentence of the standard).

I quoted the wrong part, sorry.

ISO/IEC 9899:1999 §6.3.1.3:
> [I]f the new type is unsigned, the value is converted by repeatedly adding or
> subtracting one more than the maximum value that can be represented in the new
> type until the value is in the range of the new type.

Again, well-defined.
Comment 20 Carlos Soriano 2017-03-28 19:38:33 UTC
Ah yeah, read that, but misunderstood it.
Comment 21 Vyas Giridhar 2017-03-29 15:57:52 UTC
Never knew there was a 500 page document on C standard.
I will try to take it into account from next patch