Bug 428850 - Garbage items when listing tar archives when option to show hiddens files is enabled
Summary: Garbage items when listing tar archives when option to show hiddens files is ...
Status: RESOLVED FIXED
Alias: None
Product: krusader
Classification: Applications
Component: krarc (show other bugs)
Version: Git
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krusader Bugs Distribution List
URL:
Keywords:
: 433478 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-11-08 17:47 UTC by WiseLord
Modified: 2021-02-23 19:31 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
schreenshot with tar listing (146.30 KB, image/png)
2020-11-08 17:47 UTC, WiseLord
Details

Note You need to log in before you can comment on or make changes to this bug.
Description WiseLord 2020-11-08 17:47:15 UTC
Created attachment 133154 [details]
schreenshot with tar listing

SUMMARY

When option "Show hidden files", Krusader shows some garbage content inside of tar:// archives in form of the repeating archive name in every "subdir".

The problem is reproducable only with kio-extras >= 20.08. With previous versions of kio-extras, 20.04.* problem doesn't exists.

STEPS TO REPRODUCE
1. Make sure kio-extras = 20.08
2. Open in krusader any *tar.* archive containing subdirs

OBSERVED RESULT

File list in file panel will have some garbage items named as original archive file and presented as directories

EXPECTED RESULT

There should not be any wrong items in file list

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Gentoo Linux
(available in About System)
KDE Plasma Version: 5.75.0
KDE Frameworks Version: 5.78
Qt Version: 5.15.1

ADDITIONAL INFORMATION

The bug came with the following commit in kio-extras: https://github.com/KDE/kio-extras/commit/21b86254

Probably, it's not a krusader bug and it should be fixed in kio-extras, but, on the other hand, in Dolphin the bug with the same URLs is not reproducible. So, probably Krusader should handle it and filter garbage content.
Comment 1 Méven Car 2020-11-11 06:33:10 UTC
I doubt that this has anything to do with kio-extras given krusader uses its own archive ioslave krarc.

I do reproduce.
Comment 2 Davide Gianforte 2020-11-11 07:10:26 UTC
Krusader uses an internal way to represent the contents of the filesystem. This cannot be reproduced in Dolphin.

"Show hidden files" is a good tip to start from; while the commit in kio-extras is the "cause" (should be in the ArchiveProtocolBase::createRootUDSEntry changes, but I'm not entirely sure), the solution will be internal to Krusader (excludes an element when it is the archive itself).
Comment 3 Méven Car 2020-11-11 15:19:26 UTC
(In reply to Davide Gianforte from comment #2)
> Krusader uses an internal way to represent the contents of the filesystem.
> This cannot be reproduced in Dolphin.
> 
> "Show hidden files" is a good tip to start from; while the commit in
> kio-extras is the "cause" (should be in the
> ArchiveProtocolBase::createRootUDSEntry changes, but I'm not entirely sure),
> the solution will be internal to Krusader (excludes an element when it is
> the archive itself).

I believe kio-extras change made apparent a misuse of KIO/KFileItem.
The issue I can see is krusader using indirectly UDS_DISPLAY_NAME instead of UDS_NAME as the filename, probably hidden behind some accessor (I had a look at krarc code).
Comment 4 Davide Gianforte 2020-11-11 19:46:41 UTC
Thanks for the help Meven! I followed the code in Krusader, it starts from DefaultFileSystem::refreshInternal, and in FileSystem::createFileItemFromKIO we use KFileItem in https://invent.kde.org/utilities/krusader/-/blob/master/krusader/FileSystem/filesystem.cpp#L289 (as you said) to retrieve the filename with ::text(), which returns UDS_DISPLAY_NAME while ::name() returns UDS_NAME. I think the change will be limited to this line.
Comment 5 WiseLord 2020-11-12 08:32:07 UTC
(In reply to Davide Gianforte from comment #4)
> Thanks for the help Meven! I followed the code in Krusader, it starts from
> DefaultFileSystem::refreshInternal, and in FileSystem::createFileItemFromKIO
> we use KFileItem in
> https://invent.kde.org/utilities/krusader/-/blob/master/krusader/FileSystem/
> filesystem.cpp#L289 (as you said) to retrieve the filename with ::text(),
> which returns UDS_DISPLAY_NAME while ::name() returns UDS_NAME. I think the
> change will be limited to this line.

You seem to be right, Davide. I replaced "name()" with "text()" and the problem has gone.
Comment 6 Méven Car 2020-11-13 06:47:03 UTC
(In reply to WiseLord from comment #5)
> (In reply to Davide Gianforte from comment #4)
> > Thanks for the help Meven! I followed the code in Krusader, it starts from
> > DefaultFileSystem::refreshInternal, and in FileSystem::createFileItemFromKIO
> > we use KFileItem in
> > https://invent.kde.org/utilities/krusader/-/blob/master/krusader/FileSystem/
> > filesystem.cpp#L289 (as you said) to retrieve the filename with ::text(),
> > which returns UDS_DISPLAY_NAME while ::name() returns UDS_NAME. I think the
> > change will be limited to this line.
> 
> You seem to be right, Davide. I replaced "name()" with "text()" and the
> problem has gone.

Great !

I believe you meant "text()" to "name()".

```
-    const QString name = kfi.text();
+    const QString name = kfi.name();
    // ignore un-needed entries
    if (name.isEmpty() || name == "." || name == "..") {
        return nullptr; // <- will now return null for archive root
    }
```

Who will do the honor of opening the MR ?

(I can do it it if no one else wants to)
Comment 7 WiseLord 2020-11-13 19:43:02 UTC
Yes, I've mistaken. This patch works for me:

wiselord@home ~ $ cat /etc/portage/patches/kde-misc/krusader-2.7.2/fix-tar-arhives.patch 
diff --git a/krusader/FileSystem/filesystem.cpp b/krusader/FileSystem/filesystem.cpp
index 6aafb837..e302eea1 100644
--- a/krusader/FileSystem/filesystem.cpp
+++ b/krusader/FileSystem/filesystem.cpp
@@ -286,7 +286,7 @@ FileItem *FileSystem::createFileItemFromKIO(const KIO::UDSEntry &entry, const QU
 {
     const KFileItem kfi(entry, directory, true, true);
 
-    const QString name = kfi.text();
+    const QString name = kfi.name();
     // ignore un-needed entries
     if (name.isEmpty() || name == "." || name == "..") {
         return nullptr;


(In reply to Méven Car from comment #6)
> (In reply to WiseLord from comment #5)
> > (In reply to Davide Gianforte from comment #4)
Comment 8 Bug Janitor Service 2020-11-13 20:44:23 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/krusader/-/merge_requests/35
Comment 9 Méven Car 2020-11-15 21:20:20 UTC
Git commit 98bdfe9ff649eea10112e33a68d82ae6a102ae2e by Méven Car.
Committed on 13/11/2020 at 20:36.
Pushed by meven into branch 'master'.

Filesystem: Use KFileItem::name to get files name

KFileItem::text() returns human readable values.
To get name as file on disk name we need to use name().

M  +1    -1    krusader/FileSystem/filesystem.cpp

https://invent.kde.org/utilities/krusader/commit/98bdfe9ff649eea10112e33a68d82ae6a102ae2e
Comment 10 Davide Gianforte 2021-02-23 19:31:39 UTC
*** Bug 433478 has been marked as a duplicate of this bug. ***