Android
Android copied to clipboard
Truncate export bookmarks file on overwrite
Task/Issue URL: https://github.com/duckduckgo/Android/issues/3069
Description
In Android 10/11, the "w" write mode no longer truncates the file during an overwrite. More details about this workaround can be found at https://issuetracker.google.com/issues/180526528
Steps to test this PR
- Add some bookmarks to DDG and export them.
- Delete half of the bookmarks and export them again to the same file, confirming overwriting.
- Observe the size and contents of the file.
Example non-truncated output pre-fix
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!--This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<Title>Bookmarks</Title>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1618844074" LAST_MODIFIED="1618844074" PERSONAL_TOOLBAR_FOLDER="true">DuckDuckGo Bookmarks</H3>
<DL><p>
<DT><A HREF="https://en.m.wikipedia.org/wiki/DuckDuckGo" ADD_DATE="1618844074" LAST_MODIFIED="1618844074">DuckDuckGo - Wikipedia</A>
</DL><p>
</DL><p>
/en.m.wikipedia.org/wiki/DuckDuckGo" ADD_DATE="1618844074" LAST_MODIFIED="1618844074">DuckDuckGo - Wikipedia</A>
<DT><A HREF="https://duckduckgo.com/about" ADD_DATE="1618844074" LAST_MODIFIED="1618844074">About DuckDuckGo</A>
</DL><p>
</DL><p>
Example truncated output post-fix
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!--This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<Title>Bookmarks</Title>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1618844074" LAST_MODIFIED="1618844074" PERSONAL_TOOLBAR_FOLDER="true">DuckDuckGo Bookmarks</H3>
<DL><p>
<DT><A HREF="https://en.m.wikipedia.org/wiki/DuckDuckGo" ADD_DATE="1618844074" LAST_MODIFIED="1618844074">DuckDuckGo - Wikipedia</A>
</DL><p>
</DL><p>