delete in chunks
This commit is contained in:
27
PKGBUILD
27
PKGBUILD
@@ -1,27 +0,0 @@
|
|||||||
pkgname=dull-git
|
|
||||||
pkgver=0.1
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc="Desktop app for securely storing sensitive files"
|
|
||||||
arch=('x86_64')
|
|
||||||
url="https://github.com/antpiasecki/dull"
|
|
||||||
depends=('qt6-base' 'botan')
|
|
||||||
makedepends=('cmake' 'git')
|
|
||||||
source=("git+${url}.git")
|
|
||||||
sha256sums=('SKIP')
|
|
||||||
options=('!debug')
|
|
||||||
|
|
||||||
pkgver() {
|
|
||||||
cd "${pkgname%-git}"
|
|
||||||
git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
|
||||||
cd "${pkgname%-git}"
|
|
||||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
|
|
||||||
cmake --build build -j$(nproc)
|
|
||||||
}
|
|
||||||
|
|
||||||
package() {
|
|
||||||
cd "${pkgname%-git}/build"
|
|
||||||
make DESTDIR="${pkgdir}" install
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ Desktop app for securely storing sensitive files
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
* **Pretty usable UI**
|
* **Pretty usable UI**
|
||||||
* **Overkill encryption:** XChaCha20-Poly1305 + Argon2id(m=1GB,t=6,p=4) key derivation
|
* **Overkill encryption:** XChaCha20-Poly1305 + Argon2id(m=1GB,t=8,p=4) key derivation
|
||||||
* **Cross-platform-ish:** Builds on Linux, Windows and macOS
|
* **Cross-platform-ish:** Builds on Linux, Windows and macOS
|
||||||
* **Drag and Drop support**
|
* **Drag and Drop support**
|
||||||
|
|
||||||
@@ -21,8 +21,11 @@ cmake --build build -j $(nproc)
|
|||||||
|
|
||||||
### Arch
|
### Arch
|
||||||
```
|
```
|
||||||
sudo pacman -S base-devel
|
sudo pacman -Syu base-devel cmake qt6-base botan
|
||||||
makepkg -si
|
|
||||||
|
cmake -S . -B build
|
||||||
|
cmake --build build -j $(nproc)
|
||||||
|
./build/dull
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows (MSYS2)
|
### Windows (MSYS2)
|
||||||
|
|||||||
28
src/vault.cc
28
src/vault.cc
@@ -143,21 +143,29 @@ void Vault::delete_file(const std::string &filename) {
|
|||||||
if (entry_start != -1) {
|
if (entry_start != -1) {
|
||||||
i64 entry_end = entry_start + static_cast<i64>(entry_total_size);
|
i64 entry_end = entry_start + static_cast<i64>(entry_total_size);
|
||||||
|
|
||||||
m_file.clear();
|
i64 read_pos = entry_end;
|
||||||
m_file.seekg(entry_end, std::ios::beg);
|
i64 write_pos = entry_start;
|
||||||
std::string remaining;
|
std::array<u8, 65536> buffer{};
|
||||||
remaining.assign(std::istreambuf_iterator<char>(m_file),
|
while (true) {
|
||||||
std::istreambuf_iterator<char>());
|
m_file.clear();
|
||||||
|
m_file.seekg(read_pos);
|
||||||
|
m_file.read(to_char_ptr(buffer.data()), buffer.size());
|
||||||
|
auto bytes = m_file.gcount();
|
||||||
|
if (bytes == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
m_file.clear();
|
m_file.seekp(write_pos);
|
||||||
m_file.seekp(entry_start, std::ios::beg);
|
ASSERT(m_file.write(to_char_ptr(buffer.data()), bytes));
|
||||||
ASSERT(m_file.write(remaining.data(), static_cast<i64>(remaining.size())));
|
|
||||||
|
read_pos += bytes;
|
||||||
|
write_pos += bytes;
|
||||||
|
}
|
||||||
|
|
||||||
i64 new_size = entry_start + static_cast<i64>(remaining.size());
|
|
||||||
m_file.flush();
|
m_file.flush();
|
||||||
m_file.close();
|
m_file.close();
|
||||||
|
|
||||||
std::filesystem::resize_file(m_path, new_size);
|
std::filesystem::resize_file(m_path, write_pos);
|
||||||
|
|
||||||
m_file.open(m_path, std::ios::in | std::ios::out | std::ios::binary);
|
m_file.open(m_path, std::ios::in | std::ios::out | std::ios::binary);
|
||||||
ASSERT(m_file.good());
|
ASSERT(m_file.good());
|
||||||
|
|||||||
Reference in New Issue
Block a user