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 770017 - 0 byte files should be recognized based on their .extension only
0 byte files should be recognized based on their .extension only
Status: RESOLVED OBSOLETE
Product: nautilus
Classification: Core
Component: File Properties Dialog
3.19.x
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on: 755795
Blocks:
 
 
Reported: 2016-08-17 01:57 UTC by acroq3
Modified: 2021-06-18 15:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mime-actions: guess content type when opening empty files (1.52 KB, patch)
2016-08-17 13:19 UTC, Ernestas Kulik
none Details | Review
file: infer content type from extension for empty files (2.38 KB, patch)
2016-08-18 05:58 UTC, Ernestas Kulik
none Details | Review
file: infer content type from extension for empty files (2.38 KB, patch)
2016-08-18 06:08 UTC, Ernestas Kulik
reviewed Details | Review

Description acroq3 2016-08-17 01:57:14 UTC
My use case was with csv and Calc:

When you create an empty.csv file, **it prevents you from using real csv editor** because an empty.csv will have type "plain text document (text/plain)", and only gedit-like editors will be suggested and not spreadsheet-like editors.

Right now it will suggest a LibreOffice Writer as "default editor" to empty.csv

Expected behaviour is to suggest Libre Calc for empty.csv and not text-based editors

real.csv:
1,2,3
a,b,c

empty.csv:
(0 bytes)

Details:

Idea it that popular formats doc, xlsx, csv should be always provided with their associated programs regardless of file actual contens.

0 byte files should be provided with programs based on file extension.

I also suggest to add a type "empty/empty" or "empty" file format to untie association with 0 byte "text/plain" files. 

Please forward this request to the right place it is Ubuntu specific.
Comment 1 acroq3 2016-08-17 02:15:48 UTC
xdg-mime query filetype empty.csv #1
text/plain

xdg-mime query filetype real.csv #2
text/csv
Comment 2 Ernestas Kulik 2016-08-17 05:57:38 UTC
Have you tried pressing “View All Applications”?
Comment 3 Ernestas Kulik 2016-08-17 06:03:44 UTC
(In reply to acroq3 from comment #0)
> **it prevents you from using real csv editor**
I installed LibreOffice just for this and the application chooser does not /prevent/ me from doing anything. I can get a list of all applications by pressing the button I mentioned in the previous comment.

> Idea it that popular formats doc, xlsx, csv should be always provided with
> their associated programs regardless of file actual contens.
> 
> 0 byte files should be provided with programs based on file extension.

Applications do not handle files by extension per the desktop entry specification.

> I also suggest to add a type "empty/empty" or "empty" file format to untie
> association with 0 byte "text/plain" files. 

There is no such standard type.
Comment 4 acroq3 2016-08-17 06:10:57 UTC
(In reply to Ernestas Kulik from comment #3)
> (In reply to acroq3 from comment #0)
> > **it prevents you from using real csv editor**
> I installed LibreOffice just for this and the application chooser does not
> /prevent/ me from doing anything. I can get a list of all applications by
> pressing the button I mentioned in the previous comment.
> 

My mistake, it prevents you from using Calc as "default application" instead of "all applications".

Yes, latter is possible, but you can't double click an empty.csv to open spreadsheet-like editor (and some other system will open empty.csv with Calc as default program).

> > Idea it that popular formats doc, xlsx, csv should be always provided with
> > their associated programs regardless of file actual contens.
> > 
> > 0 byte files should be provided with programs based on file extension.
> 
> Applications do not handle files by extension per the desktop entry
> specification.

Looks like it's time to extend "desktop entry specification" format, does my use case make sense now?
Comment 5 acroq3 2016-08-17 06:15:03 UTC
(In reply to Ernestas Kulik from comment #3)
> (In reply to acroq3 from comment #0)
> > I also suggest to add a type "empty/empty" or "empty" file format to untie
> > association with 0 byte "text/plain" files. 
> 
> There is no such standard type.

True, we can a file a respective request to a committee, right? If it is necessary at all...

Mime types with vendor prefixes are common, but I don't know about gnome policies and procedures about "types".
Comment 6 Ernestas Kulik 2016-08-17 13:19:38 UTC
Created attachment 333496 [details] [review]
mime-actions: guess content type when opening empty files

Currently, empty files are treated as text/plain. This can result in
less efficient workflows. This commit makes the code guess the type for
empty files.
Comment 7 Ernestas Kulik 2016-08-17 13:21:40 UTC
A little something I threw together. A thing to note is that thumbnailing should probably be changed as well, as empty files have the text file thumbnail.
Comment 8 Ernestas Kulik 2016-08-18 05:58:39 UTC
Created attachment 333543 [details] [review]
file: infer content type from extension for empty files

Currently, all empty files are treated as text/plain. This can result in
less efficient workflows (e.g. when creating files from templates and
trying to open them quickly with their type handler). This commit makes
the code guess the type for empty files from their extension.
Comment 9 Ernestas Kulik 2016-08-18 06:08:25 UTC
Created attachment 333544 [details] [review]
file: infer content type from extension for empty files

Currently, all empty files are treated as text/plain. This can result in
less efficient workflows (e.g. when creating files from templates and
trying to open them quickly with their type handler). This commit makes
the code guess the type for empty files from their extension.
Comment 10 Carlos Soriano 2016-08-19 10:01:40 UTC
Review of attachment 333544 [details] [review]:

As said on IRC, let's look into glib first, this looks like a can of worms and glib tries to not do that on pourpose.

(Also I review some code before, so I will let it here just out of curiosity)

::: src/nautilus-file.c
@@ +2448,3 @@
 	}
 
+	mime_type_uncertain = FALSE;

This looks like something to do inside the if(){}

@@ +2449,3 @@
 
+	mime_type_uncertain = FALSE;
+	mime_type = NULL;

dito

@@ +2466,3 @@
+	}
+
+			g_clear_pointer (&mime_type, g_free);

This looks like it's an "else" from the previous branch right?

if (size == 0)
else
Comment 11 André Klapper 2021-06-18 15:50:36 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version of Files (nautilus), then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/nautilus/-/issues/

Thank you for your understanding and your help.