Closed oddleaf closed 3 years ago
do you give it some time between edits? like wait 2 seconds before reopen?
SD Card&SAF I/O on Android usually is slow like snail.
Tried just now, I also clicked save and waited for some seconds before each operation to be sure. But it didn't fix.
I retested it by editing a file and keeping it open. To monitor any change, after I click save then I read the file through http server from another device.
I think I got some pattern:
hello
world
Result:
hello
world\n
hello
foo
Result:
hello
foo
d\n
It seems like... world
(5 chars) replaced by foo
(3) resulting into foo\nd
(5).
\n
after foo
seems to be caused by Markor added a newline to EOF if none of it, which is normal. But the problem is the remaining d
, it looks like residue in a buffer?
Though, there's also another \n
after d
, it is a result of previous EOF termination in step 1.
Other test results with a \n
in EOF ignored:
hello world
✕ hello wor
= hello wor\nd
hello world
✕ hello rld
= hello rld\nd
hello rld\nd
✕ hello ld
= hello ld\n\nd
hello ld\n\nd
✕ hello ld123
= hello ld123
not sure how exactly that could happen, we get the edited text as a string and write that to disk. No delta applied or something similar.
Hmmm, I see. Or probably SAF didn't truncate the file properly?
Seems to be mode "rw"
in net.gsantner.opoc.util.ShareUtil.writeFile
line 1151
is the cause:
pfd = _context.getContentResolver().openFileDescriptor(dof.getUri(), "rw");
It needs to be "rwt"
, "t"
for truncate. Please give it a try (I don't have a supported environtment to try it).
you can download test apk here when finished
Yes! It's working perfectly! Thank you! :D
Anyway, I looked at code in v2.2.8 (which is previously worked for me), the mode
was w
. But in current version is rw
, if we just writing to the file without reading it (when saving), why would it also hold r
instead of just w
or wt
?
PS: I didn't know there's such a great feature of Github, build on cloud(?).
@oddleaf Please also try this ("w") version from here https://github.com/gsantner/markor/actions/runs/485307850 . If possible please open, close, edit, rewrite, close app, switch between apps ... whatever multiple files of different sizes - let me know if you notice something wrong (or i.e. wrongfully deleted).
Any notable difference for you between w and rwt build?
PS: I didn't know there's such a great feature of Github, build on cloud(?).
It's GitHub's own Continious Integration system, GitHub Actions. There are others like CircleCi and Travis CI too.
It's GitHub's own Continious Integration system, GitHub Actions. There are others like CircleCi and Travis CI too.
Oh, thank you!
I don't see any notable difference between the two, it seems to be alright.
I don't know but if there's any behavioral change in some case like this, then please consider using wt
or rwt
instead.
I just encountered another problem... Markor crashed when I try to create empty Zim Wiki on both SD Card and internal storage. It also happens on Google Play version, I think I need to file it into another issue.
@gsantner Thank you! :)
General information
Description
Content deformed while editing file in SDCard. (Editing file in internal storage is just OK)
Seems to be the issue occurs after deleting content in a file then saving it. While adding content without removing anything seems to produce expected result.
I tested it on a Markdown file, but similar issue seems to occur also on another filetypes.
If it could be your reference... I experience this issue since v2.3.2 (but I didn't get enough time to report it. So I just reinstalled last 'stable' version I have, v2.2.8 from my backup).
How to reproduce