Files get wiped if saving when filesystem is full
- Dominant language
- Java
- Stars
- 6.1k
- Forks
- 537
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 4
Description
### ⚠️ This issue respects the following points: ⚠️
- [x] This is a **bug**. Not a [question or feature request](https://github.com/gsantner/markor/issues/new/choose).
- [x] The topic is **not** already reported at [Issues](https://github.com/gsantner/markor/issues?q=#js-issues-search). _(I've searched it)_.
- [x] Markor **is** up to date. See [Releases](https://github.com/gsantner/markor/tags) for the latest version. Updates are available from [F-Droid](https://f-droid.org/en/packages/net.gsantner.markor/) and GitHub.
- [x] The bug is still present in the latest development version (git master). (Please [download](https://nightly.link/gsantner/markor/workflows/build-android-project/master) and try the test version of Markor, named **Marder**. Don't worry; Markor and Marder appear as completely separate applications. You can install both side-by-side, and Markor settings are not touched. In case the issue is resolved there, you don't need to create a bug report. The change will be part of the next Markor update.)
### Description
I just got some of my notes destroyed and I know what happened so I feel this can be made a github issue.
So, the root filesystem in my Android phone got filled up – when the notification telling me this popped up, I was in middle of updating my QuickNote.md in Markor. I pressed the „save“ button, but then I got a popup that „Write failed“. Okay, let me go to Total Commander and move some files from the root filesystem to the extra SD card so the next write operation succeeds. Indeed the free space in the root filesystem is zero, I spend half a minute there, my move is under way, I come back to Markor to save my file. I see an empty screen, my file is empty and the data has been lost.
So, I believe that when trying to save a file when the filesystem is full and the write operation fails, it gets truncated and replaced with a zero-length file. And Markor goes to some sort of a sleep mode when switching to another program and unloads the file from the active memory and then reloads it from the filesystem when coming back.
The result is that the „save“ button is deadly for data when the filesystem is full and the filesystem write call fails.
Please fix this. Or at least give us an option to make a simple .bak backup copy of the file before saving it.
### Steps to reproduce
1. Fill the root filesystem (or the one where the file resides).
2. Update a note, press „save“.
3. Go to home screen or another program.
4. Come back to Markor.
5. Boom, the file is gone.
### Information
Android version: 8.0.0
Device: Samsung A8
App Version: v2.13.1 (156)
### Source
F-Droid
### Format / File type
Markdown
### Additional info / Log
```shell
-
```
Contributor guide
No contributing guide indexed for this repository
Research direction
No source file or test is named. Start by locating the save-button path and the write-failure handling, then reproduce the reported sequence with the filesystem full. Done means a failed save does not leave the existing file empty, with the stated reproduction steps covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100