From: Ian Beckwith Date: Fri, 24 Sep 2010 01:18:59 +0000 (+0100) Subject: last_update: store in id3fs table, update when index is updated, X-Git-Tag: debian/1.0-1~183 X-Git-Url: http://erislabs.net/gitweb/?p=id3fs.git;a=commitdiff_plain;h=dc887285c5120a0da46bb243c7dd390e0148b873 last_update: store in id3fs table, update when index is updated, use as timestamp for everything --- diff --git a/bin/id3fs b/bin/id3fs index 547b96d..62a631e 100755 --- a/bin/id3fs +++ b/bin/id3fs @@ -34,6 +34,7 @@ if(@ARGV > 1 && !defined($basedir)) } my $db=ID3FS::DB->new($me, $dbpath, $basedir, $ARGV[0]); +$db->last_update(time()); while(my $path=shift) { diff --git a/lib/ID3FS/DB.pm b/lib/ID3FS/DB.pm index 11381c6..b6570ce 100644 --- a/lib/ID3FS/DB.pm +++ b/lib/ID3FS/DB.pm @@ -84,7 +84,8 @@ sub create $self->{dbh}->do("CREATE INDEX $index ON " . $indexes{$index}); } } - $self->cmd("INSERT INTO id3fs (schema_version) VALUES (?)", $SCHEMA_VERSION); + $self->cmd("INSERT INTO id3fs (schema_version, last_update) VALUES (?, ?)", + $SCHEMA_VERSION, time()); } sub checkschema @@ -99,6 +100,20 @@ sub checkschema } } +sub last_update +{ + my($self, $newval)=@_; + if(defined($newval)) + { + $self->cmd("UPDATE id3fs SET last_update=?", $newval); + } + else + { + ($newval)=$self->cmd_onerow("SELECT last_update from id3fs"); + } + return $newval; +} + sub cmd_sth { my($self, $sql, @params)=@_; @@ -548,7 +563,8 @@ sub last_insert_id __DATA__ CREATE TABLE id3fs ( - schema_version INTEGER + schema_version INTEGER, + last_update ); CREATE TABLE files ( diff --git a/lib/ID3FS/Fuse.pm b/lib/ID3FS/Fuse.pm index cc38b65..732dd71 100644 --- a/lib/ID3FS/Fuse.pm +++ b/lib/ID3FS/Fuse.pm @@ -65,12 +65,13 @@ sub getattr my($self, $filename)=@_; print "**GETATTR: $filename\n"; my $path=ID3FS::Path->new($self->{db}, $filename); + my $last_update=$self->{db}->last_update(); return(-ENOENT()) unless($path->isvalid()); my($dev,$ino,$nlink)=(0,0,1); my $uid=$<; my $gid=(split(/ /, $( ))[0]; my($rdev,$size)=(0,1); - my($atime,$mtime,$ctime)=(0,0,0); + my($atime,$mtime,$ctime)=($last_update) x 3; my($blksize,$blocks)=(512,1); my $mode=$self->mode( $path->isdir() ? $TYPE_DIR : $TYPE_SYMLINK ); return($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,