New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify attachment #9
Conversation
c9ad527
to
0f3c542
Compare
0f3c542
to
179289f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was left halfway reviewed and now has been conflicting too on one place.
Guess it should be mostly ok, left a couple comments. Slightly still a bit unsure how these attachment play along when the saved file can be deleted while the message content remains downloaded, etc.
179289f
to
0b38b20
Compare
|
Still needs a rebase |
Don't duplicate the download path in the agent and the attcahment list model.
…lAgent. Move the code to handle attachment saving all into EmailAgent. Also change the attachmentDownloadStatus() inquire routines so it can return if an attachment has already been downloaded or not.
0b38b20
to
59694af
Compare
|
Sorry, I noticed the rebase status too late before going to eat...
If I'm not mistaken, the new code path in that case should be the following:
Actually, this was supposed to be the former code path also, since the changes are about the Which finally raises a question : what happen now if the file is deleted while the email is opened, since there is not disk monitoring anymore... I need to check. |
|
Testing on device, it seems that deleting an attachment (for example opening a PDF in the document application, and deleting it there), and coming back to the email application already creates an issue before this PR. Taping again on the attachment in the email view does not open the attachment anymore and raise a notification that the file does not exists. Actually the old FileWatcher object was not looking at file deletion, as far as I can tell in the callback. Maybe we can have a separated PR for this specific issue ? |
|
Yea, not sure if the current situation with transient downloaded state and not following the deletion while in view is any better. What I also tested this seemed mostly comparable so indeed any other changes can be done separately. Surprisingly tricky this downloaded state, and if changes done, those could be needed jolla-email app too. Thinking if it would be better to consider downloaded (content in qmf), and saved (file created on disk) more separate states. Also would be nice if we didn't need to use that downloaded file structure, perhaps ideally downloaded files would be just put into generic downloads folder. But if you're ok having this in now(?), I could integrate. |
I would love to address this, surely. Having the save path in a unique function in the EmailAgent as proposed in this PR is a first step, I think. We also need to keep the possibility to easily delete all saved files when deleting the email account. So we need to keep the first path level (made up from the account id, or what ever). Or, should we ? When deleting the email account, should we instead just delete the QMF downladed parts and not touch to the saved ones ? For the file themselves, there is no need to add more path hierarchy with the mail id and the part id. Just saving with the provided filename, appending a -%XX number if necessary to avoid collision would be enough. And much simpler to recover where the file is located when navigating with a file browser for instance.
That's a very good suggestion. Indeed, that means to have a little change in jolla-email. I'll give a look in a separated PR for these.
This issue is also a separated one. I need to bring back a FileWatcher over the saved files to change the status to |
I think it should be sufficient to delete only the qmf content on account removal. The saved file is requested by the user so in a way it's owned by the user.
Tricky part there could be the case when user reopens an email and opens an attachment. If it's already saved as a file (and still exists), that file should be opened and no new one created. Thus probably need to store the saved filename somewhere.
Pondering how we'd really need the file watcher. Guess mostly this matters when the attachment is opened at which time the existence could be checked too. Also deleting the file would be still sort of "Downloaded" state if the data is in qmf side. |
I totally share this point of view. I'll keep it in mind when touching the saving mechanism. It may require to give a look to the buteo email plugin or to the account components, if the directory under
Ah, sure, thanks for reminding this use case. I forgot about it. It's a tricky part. Need more thoughts about it.
I'm proposing as an additional commit a solution for the attachment deletion issue using a FileWatcher. I agree that it could be done differently by requesting to the EmailAgent the path when using the url getter. What do you prefer :
|
Was pondering myself something like nemo-email or app specific database for the attachment location -> file mappings. Or if qmf allowed to store some extra metadata then that could be an option.
For one thing that could be better if it didn't add separate files to the watcher as there are limits how many things can be tracked with inotify. Limit maybe not easily reached, but the app could be running for some time. But as the file deletion is a different issue, maybe let's just drop it here and integrate the existing things first, shall we. |
42bca8f
to
59694af
Compare
Ok, sure. I've removed the additional commit. I'll submit it in a separated PR. |
Try to centralise the code responsible of copying attachments into the Downloads directory in EmailAgent only. Also make this a private implementation in EmailAgent. It avoids code duplication and put the attachment related operations in one place only : the agent.
To achieve this:
DownloadedandNotDownloadedstatus by inquiring the presence of the destination file instead of delegating this to attachmentlistmodel,resetModel()from attachmentlistmodel.cpp has been simplified to rely only on the status and the path reported by the agent.@rainemak , this brings me to ask you why you added a QFileWatcher in attachmentlistmodel with commit edce7bd ? The commit message is a bit unclear about this specific addition. It dealt with the change in downloadAttachment to return a boolean (which is great) and with the fact that the URL is empty if the file has not been saved yet (which is fine also). It seems to me that the
EmailAgent::attachmentPathChangedsignal would be enough for attachment that are required to be downloaded. I tested the PR here with a POP3 account where the email content is always downloaded and with an IMAP4 one, where I looked at already downloaded attachment, or triggered download on tap. All cases seemed to work.Additionally, this also reduces the complexity in AttachmentListModel and save roughly 50 lines all in all. @pvuorela, may you give a look into this also when you will have the time to ?