mirror of
https://codeberg.org/scip/note.git
synced 2025-12-17 04:31:02 +01:00
FIXED: most config variables not related to drivers had
invalid sentence in note, so the new ones of the new config
were ignored.
FIXED: added version to NOTEDB::text.
FIXED: fixed handling of NOTEDB::crypt_supported, now encryption
works again.
ADDED: NOTEDB::text now supports internal caching too.
CHANGED: lock() sets the umask internally to 022, so that other
users are able to read the lockfile.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
package NOTEDB::general;
|
||||
|
||||
$NOTEDB::general::VERSION = "1.00";
|
||||
$NOTEDB::general::VERSION = "1.01";
|
||||
|
||||
use strict;
|
||||
#use Data::Dumper;
|
||||
@@ -258,6 +258,7 @@ sub uen {
|
||||
eval {
|
||||
$crypted = $this->{cipher}->encrypt($raw);
|
||||
};
|
||||
print $@;
|
||||
}
|
||||
else {
|
||||
$crypted = $raw;
|
||||
@@ -287,8 +288,13 @@ sub _store {
|
||||
open NOTE, ">$this->{dbname}" or die "could not open $this->{dbname}: $!\n";
|
||||
flock NOTE, LOCK_EX;
|
||||
|
||||
my $content = SaveConfigString($data) or die "could not serialize data: $!\n";
|
||||
print NOTE $content;
|
||||
if (%{$data}) {
|
||||
my $content = SaveConfigString($data) or die "could not serialize data: $!\n";
|
||||
print NOTE $content;
|
||||
}
|
||||
else {
|
||||
print NOTE "";
|
||||
}
|
||||
|
||||
flock NOTE, LOCK_UN;
|
||||
close NOTE;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
package NOTEDB::text;
|
||||
|
||||
$NOTEDB::text::VERSION = "1.01";
|
||||
|
||||
use strict;
|
||||
#use Data::Dumper;
|
||||
use File::Spec;
|
||||
@@ -40,6 +42,9 @@ sub new {
|
||||
}
|
||||
|
||||
$self->{LOCKFILE} = $param{dbname} . "~LOCK";
|
||||
$self->{mtime} = $self->get_stat();
|
||||
$self->{unread} = 1;
|
||||
$self->{data} = {};
|
||||
|
||||
return $self;
|
||||
}
|
||||
@@ -52,9 +57,14 @@ sub DESTROY
|
||||
|
||||
sub version {
|
||||
my $this = shift;
|
||||
return $this->{version};
|
||||
return $NOTEDB::text::VERSION;
|
||||
}
|
||||
|
||||
sub get_stat {
|
||||
my ($this) = @_;
|
||||
my $mtime = (stat($this->{dbname}))[9];
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
|
||||
sub set_del_all {
|
||||
@@ -268,8 +278,12 @@ sub _store {
|
||||
sub _retrieve {
|
||||
my $this = shift;
|
||||
if (-s $this->{NOTEDB}) {
|
||||
my $data = lock_retrieve($this->{NOTEDB});
|
||||
return %{$data};
|
||||
if ($this->changed() || $this->{unread}) {
|
||||
my $data = lock_retrieve($this->{NOTEDB});
|
||||
$this->{unread} = 0;
|
||||
$this->{data} = $data;
|
||||
return %{$data};
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ();
|
||||
|
||||
Reference in New Issue
Block a user