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

Add an additional free disk space check before saving the datastore #1913

Merged
merged 1 commit into from
Nov 25, 2022

Conversation

ArthurHoaro
Copy link
Member

On every disk write operation, we check the available free disk space (+ slight marging of arbitrary 500kB), and if there is not enough space we do not attempt to write anything.

This should prevent most case of corrupted datastore becoming an empty file due to full HDD.

Fixes #1810

On every disk write operation, we check the available free disk space (+ slight marging of arbitrary 500kB),
and if there is not enough space we do not attempt to write anything.

This should prevent most case of corrupted datastore becoming an empty file due to full HDD.

Fixes shaarli#1810
Copy link
Member

@nodiscc nodiscc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

$data = self::$phpPrefix . base64_encode(gzdeflate(serialize($links))) . self::$phpSuffix;
$data = base64_encode(gzdeflate(serialize($links)));

if (empty($data)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would an empty $data happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If, for any kind of reason, PHP was not able to serialize or compress the bookmarks data.
Sometimes, an invalid UTF-8 character can mess up everything with PHP functions. Better be safe than sorry.

@ArthurHoaro ArthurHoaro merged commit 84b37c7 into shaarli:master Nov 25, 2022
@ArthurHoaro ArthurHoaro deleted the feature/disk-space branch November 25, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datastore corruption when the disk is full
2 participants