Skip to content
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

v2.8.2: ShareInto/QuickNote Markor not saving #1482

Closed
Ssmur opened this issue Nov 4, 2021 · 11 comments
Closed

v2.8.2: ShareInto/QuickNote Markor not saving #1482

Ssmur opened this issue Nov 4, 2021 · 11 comments
Assignees
Labels
Milestone

Comments

@Ssmur
Copy link

Ssmur commented Nov 4, 2021

General information

  • App version: 2.8.2 (F-Droid)
  • Android version: 8.1
  • Device: OnePlus 5T
  • I understand that this issue will be closed without further notice in case I didn't describe the problem including general information, or didn't search for similar issues & requests.

Description

Today I've updated Markor (2.8.1) to (2.8.2).
In Firefox, press Share button to save URL, paste the note on a large file I have of links saved, and Markor when ask where to insert the note, I choose that file (bookmarksff.md) and open the file cmpletly erased everything, 0 bytes. I have create other dummy file (markdown), write something random, Save, close file and open it again, there are the text. I repeat the process of save a Url from Firefox to Markor and choose that dummy file, and again, the file auto-delete its content, does not even enter the Url I want to save.
I wil try with a Xiaomi 6a, and update the result.

[UPDATE] Well, in a Xiaomi 6a Stock rom MIUI 11.0.8 reproduces the same behaviour. In this case, I open a app of F-Droid catalog, press ShareInto button, select Markor, select file of notes and got erased its content.

@gsantner
Copy link
Owner

gsantner commented Nov 4, 2021

probably from #1473 , though using this a lot haven't seen it yet

(letting know @harshad1 too)

@gsantner gsantner changed the title Sharing action from 3rd app to Markor, the file of notes get erased its content. v2.8.2: ShareInto Markor saving Nov 4, 2021
@gsantner gsantner changed the title v2.8.2: ShareInto Markor saving v2.8.2: ShareInto Markor not saving Nov 4, 2021
@gsantner gsantner added the bug label Nov 4, 2021
@gsantner gsantner added this to the 2.9 milestone Nov 4, 2021
@gsantner gsantner changed the title v2.8.2: ShareInto Markor not saving v2.8.2: ShareInto/QuickNote Markor not saving Nov 4, 2021
@harshad1
Copy link
Collaborator

harshad1 commented Nov 4, 2021

Relevant code

https://github.com/gsantner/markor/blob/master/app/src/main/java/net/gsantner/markor/activity/DocumentShareIntoFragment.java#L203-L220

I don't see an obvious bug in the code


On fail we return content = ""

https://github.com/gsantner/markor/blob/master/app/src/main/java/net/gsantner/markor/model/Document.java#L230-L231

I think it would be better to not hide the exception and force the calling code to handle an exception. That way, we can prevent writes if there was an exception on read.


I can reproduce this issue. Happens with encrypted files. No. Can reproduce with all files now :(

@gsantner
Copy link
Owner

gsantner commented Nov 4, 2021

I'm setting up android dev on a new OS. As far I read there is also an issue with QuickNote/todo.txt/Main page, so might be outside the ShareIntoFragment

hehe, once more "we don't save empty files, too much tears about lost files" 😃

though I had tried main page, sharing stuff, creating new files, editing files...haven't had the case

@harshad1
Copy link
Collaborator

harshad1 commented Nov 4, 2021

hehe, once more "we don't save empty files, too much tears about lost files" 😃

Sigh.

I'll look into solving the root cause in the evening

Will also add the empty files logic back in

@gsantner
Copy link
Owner

gsantner commented Nov 4, 2021

thanks for your quick help

I finished downloading android sdk now ... also working on it

merged comments a little

Repository owner deleted a comment from harshad1 Nov 4, 2021
Repository owner deleted a comment from harshad1 Nov 4, 2021
Repository owner deleted a comment from harshad1 Nov 4, 2021
@gsantner
Copy link
Owner

gsantner commented Nov 4, 2021

@harshad1
hmm, I have the current master installed, however sharing into works, no loss at quicknote/todo, and also not when normal opening/closing a file.

I can only reproduce an issue when selecting some a file from filemanager in the popup dialog, from i.e. recent/popular files. So what @Ssmur described, but not #1483 .

This problem may stem from this: File::write might be still doing stuff on low level I/O, which we don't notice. And when we immediately open the file while this in progress, it possibly is still empty at that point.
At QuickNote/todo.txt we only write, but don't open the activity.

screenrecord-2021-11-04_20.08.49.mp4

gsantner added a commit that referenced this issue Nov 4, 2021
@gsantner
Copy link
Owner

gsantner commented Nov 4, 2021

@Ssmur @kylesorkness @harshad1
Can you please try the build of this app, and check if the issue is still present? The download button is the
android-apk, below all. The app is a debug build which can be installed beside Markor, and is named Mordor.
(For testing, ShareInto Mordor)

https://github.com/gsantner/markor/actions/runs/1422885489

@harshad1
Copy link
Collaborator

harshad1 commented Nov 4, 2021

Yeah. I am seeing this too.

It may be possible to address this by making the IO functions static? That way the synchronized will not be instance specific.

@gsantner
Copy link
Owner

gsantner commented Nov 4, 2021

new insight: document is transferred from ShareInto, it has modTime set from the time of adding the additional text. when document.read call is running at the DocumentEditor, it sees file was already read (modTime == current file.modTime()) and it not read again as expected. (Per se ok, just that the texteditor is empty, and no file was read previously at THIS editor) ---> added resetting of modTime prior passing on to DocumentEditor initializer.

@gsantner gsantner self-assigned this Nov 4, 2021
@Ssmur
Copy link
Author

Ssmur commented Nov 4, 2021

@gsantner @harshad1
Hi, good news, I tested the build you posted. And now doing the same, does not erase the text saved previously.
I have repeated three times the steps for make sure the bug it's fixed. Included saving in Quicknote, To-Do and custom file.
Seems fixed to me.

@harshad1
Copy link
Collaborator

@gsantner This is now solved right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants