Rename dialog displays also source file information
AcceptedPublic

Authored by papoteur on Feb 5 2020, 10:01 PM.

Details

Reviewers
elvisangelaccio
rthomsen
Group Reviewers
Ark
Summary

This patch is for solving:
Bug 403146 - Extracting suggests replacement file with info of destination file
I have tested with ark 19.04.0. It allows to have size and date of the source file from the archive, not the destination information.
The modifications are :

  • call overwriteQuery with information from the source file, not only the entry name.

BUG: 403146
FIXED-IN: 20.12

Test Plan

Create an archive.
Modify a file which copy is in the archive
Open it with ark, extract the archive at the same location. A dialog opens to replace the file. At left, the information (date, size) should be the information before modification, and at right, from the modified file.
Extract or not.

Diff Detail

Repository
R36 Ark
Lint
Lint Skipped
Unit
Unit Tests Skipped
There are a very large number of changes, so older changes are hidden. Show Older Changes
Restricted Application added a subscriber: kde-utils-devel. · View Herald TranscriptFeb 5 2020, 10:01 PM
papoteur requested review of this revision.Feb 5 2020, 10:01 PM
meven edited the summary of this revision. (Show Details)Feb 8 2020, 8:20 AM
meven added a reviewer: elvisangelaccio.
meven edited the summary of this revision. (Show Details)
meven added a subscriber: meven.Feb 8 2020, 8:27 AM

Nice first patch @papoteur , seems good to me.
Great on you pushing through your patch to phabricator.

Please fix the few formatting issues.
Then we leave the final say to Ark maintainer @elvisangelaccio

kerfuffle/queries.cpp
87

indentation seems wrong here.

95

A space too much

kerfuffle/queries.h
72

Please remove this unneeded end space

104

Same

papoteur updated this revision to Diff 75255.EditedFeb 8 2020, 2:30 PM

Hello,
This patch has corrections for comments.

meven added a comment.Feb 8 2020, 4:45 PM

Btw, You can mark the comment you treated as "Done" in phabricator, it it eases the review work.

papoteur marked 4 inline comments as done.EditedFeb 8 2020, 4:55 PM

Btw, You can mark the comment you treated as "Done" in phabricator, it it eases the review work.

This is what I have done, by ticking the checkbox. Is there something else to do? Do you need to update the page?
I'm not comfortable with the interface and the process. I wonder if the patch is integrated in a test build.

What also confuses me is that bugzilla and phabricator each require their own identity.

elvisangelaccio requested changes to this revision.Mar 15 2020, 6:55 PM

Thanks for the patch. This is a good start, but it needs some work.

The problem is we shouldn't use libarchive functions in queries.cpp. It's the wrong layer. We should add new API instead, so that we can call this API from all the plugins (not only libarchive).

So we should add something like setCreationTime() / setModificationTime() to the Query classes and call these new methods from the libarchive plugin. Bonus point if you fix all the plugins of course ;)

This revision now requires changes to proceed.Mar 15 2020, 6:55 PM

Hello,
I tried further. I understood how to create a call to add information needed about source file. However, my calls to this function seem to never occur. With a debugger, I see that calls come from jobs, and I don't understand this mechanism.

meven added a comment.Apr 11 2020, 7:16 AM

Hello,
I tried further. I understood how to create a call to add information needed about source file. However, my calls to this function seem to never occur. With a debugger, I see that calls come from jobs, and I don't understand this mechanism.

I am not familiar with this code base, I would need to see some of you code to see what you mean.

Hello,
I tried further. I understood how to create a call to add information needed about source file. However, my calls to this function seem to never occur. With a debugger, I see that calls come from jobs, and I don't understand this mechanism.

Please update this patch, so we can test your code.

papoteur updated this revision to Diff 79931.Apr 12 2020, 2:23 PM

This new patch provides data from source by calling setSourceData.
However, from my tests, it is never called.

meven added a comment.Apr 13 2020, 7:42 AM

This new patch provides data from source by calling setSourceData.

This looks nice.

However, from my tests, it is never called.

You might need to edit the other plugins. You could be using another plugin than cliinterface and libarchive without knowing.

The other other code path concerned :

plugins/libzipplugin/libzipplugin.cpp
650:                Kerfuffle::OverwriteQuery query(renamedEntry);

plugins/libsinglefileplugin/singlefileplugin.cpp
121:        Kerfuffle::OverwriteQuery query(newFileName);

Other than that, I can recommend you some good old debugging, to see where the calls stops.

kerfuffle/queries.cpp
39

Can remove

104

We use same line { for if and else (with preceeding space).

105

sourceUrl can stay out of if/else

120

We prefer } else {

rthomsen requested changes to this revision.Apr 26 2020, 5:09 PM
rthomsen added a subscriber: rthomsen.

I think it makes sense to always require specifying ctime, mtime and size, so please add the three values as arguments to the constructor of OverwriteQuery so we can get rid of setSourceData() and m_from_archive.

kerfuffle/queries.cpp
44

The data you set are not used when sourceUrl points to an existing local file (see link).
So sourceUrl should be set to just the filename i.e.:
QUrl sourceUrl = QUrl(m_data.value(QStringLiteral("filename")).toString());

This revision now requires changes to proceed.Apr 26 2020, 5:09 PM
rthomsen set the repository for this revision to R36 Ark.Apr 26 2020, 5:14 PM
papoteur updated this revision to Diff 81813.May 3 2020, 5:40 PM

This version modifies the function signature of OverwriteQuery to pass directly data from source file.
Call to the function are adapted in the whole repo. I have tested it with extraction of one single file and a complete archive. Thus I have tested only the call from libarchiveplugin, line 306. I don't know how to test other calls.

rthomsen requested changes to this revision.May 3 2020, 9:43 PM

Almost ready :)

kerfuffle/cliinterface.cpp
598–600

dirIt.filePath() points to the source file so create a QFileInfo and use that to get the properties. Also please use QFileInfo::birthTime() and QFileInfo::lastModified() here to get ctime and mtime, respectively.

979

In this case we can't easily get the properties of the source file, so I guess we should do the same as previously and just send the destination file properties. You should use QDir::current().path() + QLatin1Char( '/' ) + m_storedFileName then.

Also please use QFileInfo::birthTime() and QFileInfo::lastModified().

kerfuffle/queries.h
85

We mostly use camelcase-style in Ark so please call these arguments: ctimeSrc, mtimeSrc and sizeSrc (and the member variables the same just prefixed with m_.

plugins/libsinglefileplugin/singlefileplugin.cpp
123–124

Please use QFileInfo::birthTime() and QFileInfo::lastModified().

plugins/libzipplugin/libzipplugin.cpp
651

Zip format doesn't store ctime, so guess it makes sense to pass mtime for both.

This revision now requires changes to proceed.May 3 2020, 9:43 PM
papoteur updated this revision to Diff 81938.May 4 2020, 7:59 PM

Should be OK now.

meven added a comment.May 5 2020, 6:03 AM

Should be OK now.

You missed a couple of small things.

Marking comments treated as "DONE" can be quite handy, to find the ones left quicker.

plugins/libsinglefileplugin/singlefileplugin.cpp
123–124

you missed here

plugins/libzipplugin/libzipplugin.cpp
651

And here, but I guess, there is nothing to do.

papoteur updated this revision to Diff 81972.May 5 2020, 7:14 AM
papoteur marked 8 inline comments as done.
rthomsen requested changes to this revision.May 5 2020, 8:52 AM

Some nitpicks. I tested the patch and it works as intended :)

kerfuffle/cliinterface.cpp
474–477

Please fix indentation.

980–985

No longer needed.

982

First argument can now be simplified to: destFile.filePath()

kerfuffle/queries.h
85

You didn't change the name of the arguments and member variables as instructed in my previous comment. Please fix.

plugins/libarchive/libarchiveplugin.cpp
307–310

Fix indentation please.

plugins/libzipplugin/libzipplugin.cpp
651–654

Fix indentation please.

This revision now requires changes to proceed.May 5 2020, 8:52 AM
rthomsen set the repository for this revision to R36 Ark.May 5 2020, 10:38 AM
papoteur added inline comments.May 6 2020, 6:46 AM
plugins/libarchive/libarchiveplugin.cpp
307–310

Sorry, I don't know the rule that can govern the indentation.
This one is given by qtcreator.

rthomsen added inline comments.May 6 2020, 8:05 AM
plugins/libarchive/libarchiveplugin.cpp
307–310

Ok, no worries. Just fix the two other remaining items so we can commit this :)

papoteur updated this revision to Diff 82309.May 8 2020, 7:53 PM
papoteur marked 5 inline comments as done.
papoteur edited the summary of this revision. (Show Details)

And now?

rthomsen accepted this revision.May 9 2020, 8:23 AM

Great. Nice work :) Do you have commit access or should I commit it for you?

No, I don't have commit credentials. Go for myself.

No, I don't have commit credentials. Go for myself.

Can you provide full name for commit message or should I use your nickname? And can you provide email-address?

elvisangelaccio accepted this revision.May 11 2020, 5:57 PM
This revision is now accepted and ready to land.May 11 2020, 5:57 PM

I have tested this patch myself on Arch Linux.
Previews of jpg flles don't work as expected,
the one below "Source" is not generated and below "Destination"
we see the preview of source file.

That's because the source is still compressed and we can't get a preview out of it.

My screenshot is showing preview of the compressed file (source) as "destination".

Ah right, sorry :P

My screenshot is showing preview of the compressed file (source) as "destination".

Hi Patrick,
Is it different with the original ark?

My screenshot is showing preview of the compressed file (source) as "destination".

Hi Patrick,
Is it different with the original ark?

Ark 20.04.1 from Arch repos shows the thumbnail of source file twice.

Ark 20.04.1 from Arch repos shows the thumbnail of source file twice.

Hi, how do you enable preview? I have enabled preview in Dolphin, but this doesn't seem to have effect. I can't get any preview, either for source or destination.

I have done nothing special to enable previews on Arch Linux.
I can confirm missing previews on neon unstable edition despite preview of images in Dolphin is enabled on both systems.

My screenshot is showing preview of the compressed file (source) as "destination".

Hi Patrick,
Is it different with the original ark?

Ark 20.04.1 from Arch repos shows the thumbnail of source file twice.

Hello, I have had a deeper look on how previews are got. Preview are first looked at in a cache directory. Thus, when the source or destination matches an already existing preview, this one is displayed. This explain why your previews are the same for source and destination or are mixed.
If this is a bug, this is not in ark, but in KIO. And it should not prevent to release a fix for this one.

meven edited the summary of this revision. (Show Details)Oct 24 2020, 5:51 AM

No, I don't have commit credentials. Go for myself.

Can you provide full name for commit message or should I use your nickname? And can you provide email-address?

Use my nickname: Papoteur
And a fake email address, if needed.
Papoteur

Hello all,
Is there someone to commit this change?
Papoteur

meven added a comment.Oct 31 2020, 1:52 PM

Hello all,
Is there someone to commit this change?
Papoteur

I am not sure we can use a nickname as author because of licensing.

I am not sure we can use a nickname as author because of licensing.

Why not?
Copyright protects the rights of the author. On one side, patrimonial rights allow to give him money, but with open source licence, the author says that he waives to them. On another side, moral right allows him to be cited as author. If he wants to be cited with a nickname, it's also his right.

meven added a comment.Oct 31 2020, 5:33 PM

I am not sure we can use a nickname as author because of licensing.

Why not?
Copyright protects the rights of the author. On one side, patrimonial rights allow to give him money, but with open source licence, the author says that he waives to them.

Well he grants them, but he keeps all his rights, like the ability to change the license to his work that is not transferable through a license but only through a FLA or such.

On another side, moral right allows him to be cited as author. If he wants to be cited with a nickname, it's also his right.

Rights are only applicable to people i.e with identity. A nickname has no legal existence thus cannot have legal rights.
https://community.kde.org/Policies/Licensing_Policy states that commits must have commit author's names (and email).
But I am not too sure how much we would enforce this.

meven added a comment.Nov 3 2020, 5:46 PM

@papoteur
Do you realize your email is already pretty-much public on bugzilla and it contains your name ?