[Pyukiwiki-cvs 0004277] CVS update: PyukiWiki-Devel/lib/Nana

Back to archive index

PyukiWiki CVS Commit pyuki****@lists*****
2012年 1月 30日 (月) 16:41:15 JST


Index: PyukiWiki-Devel/lib/Nana/YukiWikiDB.pm
diff -u PyukiWiki-Devel/lib/Nana/YukiWikiDB.pm:1.406 PyukiWiki-Devel/lib/Nana/YukiWikiDB.pm:1.407
--- PyukiWiki-Devel/lib/Nana/YukiWikiDB.pm:1.406	Mon Jan 30 09:24:47 2012
+++ PyukiWiki-Devel/lib/Nana/YukiWikiDB.pm	Mon Jan 30 16:41:15 2012
@@ -1,8 +1,8 @@
 ######################################################################
 # YukiWikiDB.pm - This is PyukiWiki, yet another Wiki clone.
-# $Id: YukiWikiDB.pm,v 1.406 2012/01/30 00:24:47 papu Exp $
+# $Id: YukiWikiDB.pm,v 1.407 2012/01/30 07:41:15 papu Exp $
 #
-# "Nana::YukiWikiDB" version 0.4 $$
+# "Nana::YukiWikiDB" version 0.6 $$
 # Author: Nanami
 # http://nanakochi.daiba.cx/
 # Copyright (C) 2004-2012 Nekyo
@@ -19,7 +19,7 @@
 ######################################################################
 
 package Nana::YukiWikiDB;
-$VERSION="0.4";
+$VERSION="0.6";
 use strict;
 use Nana::File;
 
@@ -34,7 +34,7 @@
 	return undef;						# debug
 }										# debug
 
-# tying
+# tying												# comment
 sub TIEHASH {
 	my ($class, $dbname) = @_;
 	my $self = {
@@ -53,28 +53,29 @@
 # Store												# comment
 sub STORE {
 	my ($self, $key, $value) = @_;
-	my $filename = &make_filename($self, $key);
+	my ($mode, $filename) = &make_filename($self, $key);
 	return Nana::File::lock_store($filename,$value);
 }
 
 # Fetch												# comment
 sub FETCH {
 	my ($self, $key) = @_;
-	my $filename = &make_filename($self, $key);
+	my ($mode, $filename) = &make_filename($self, $key);
+	return (stat($filename))[9] if($mode eq "update");
 	return Nana::File::lock_fetch($filename);
 }
 
 # Exists											# comment
 sub EXISTS {
 	my ($self, $key) = @_;
-	my $filename = &make_filename($self, $key);
+	my ($mode, $filename) = &make_filename($self, $key);
 	return -e($filename);
 }
 
-# Delete
+# Delete											# comment
 sub DELETE {
 	my ($self, $key) = @_;
-	my $filename = &make_filename($self, $key);
+	my ($mode, $filename) = &make_filename($self, $key);
 	return Nana::File::lock_delete($filename);
 }
 
@@ -102,9 +103,13 @@
 
 sub make_filename {
 	my ($self, $key) = @_;
+	my $mode="";
+	if($key=~/^\_\_(.+?)\_\_(.+?)$/) {
+		$mode=$1;
+		$key=$2;
+	}
 	$key =~ s/(.)/$::_dbmname_encode{$1}/g;
-
-	return $self->{dir} . "/$key.txt";
+	return ($mode, $self->{dir} . "/$key.txt");
 }
 
 1;
Index: PyukiWiki-Devel/lib/Nana/YukiWikiDB_GZIP.pm
diff -u PyukiWiki-Devel/lib/Nana/YukiWikiDB_GZIP.pm:1.149 PyukiWiki-Devel/lib/Nana/YukiWikiDB_GZIP.pm:1.150
--- PyukiWiki-Devel/lib/Nana/YukiWikiDB_GZIP.pm:1.149	Mon Jan 30 09:24:47 2012
+++ PyukiWiki-Devel/lib/Nana/YukiWikiDB_GZIP.pm	Mon Jan 30 16:41:15 2012
@@ -1,8 +1,8 @@
 ######################################################################
 # YukiWikiDB_GZIP.pm - This is PyukiWiki, yet another Wiki clone.
-# $Id: YukiWikiDB_GZIP.pm,v 1.149 2012/01/30 00:24:47 papu Exp $
+# $Id: YukiWikiDB_GZIP.pm,v 1.150 2012/01/30 07:41:15 papu Exp $
 #
-# "Nana::YukiWikiDB_GZIP" version 0.5 $$
+# "Nana::YukiWikiDB_GZIP" version 0.6 $$
 # Author: Nanami
 # http://nanakochi.daiba.cx/
 # Copyright (C) 2004-2012 Nekyo
@@ -19,7 +19,7 @@
 ######################################################################
 
 package Nana::YukiWikiDB_GZIP;
-$VERSION="0.5";
+$VERSION="0.6";
 use strict;
 use Nana::File;
 use Nana::GZIP;
@@ -35,7 +35,7 @@
 	return undef;						# debug
 }										# debug
 
-# tying
+# tying												# comment
 sub TIEHASH {
 	my ($class, $dbname) = @_;
 	my $self = {
@@ -54,8 +54,8 @@
 # Store												# comment
 sub STORE {
 	my ($self, $key, $value) = @_;
-	my $filename = &make_filename($self, $key);
-	my $filename_gz = &make_filename_gz($self, $key);
+	my ($mode, $filename) = &make_filename($self, $key);
+	my ($mode, $filename_gz) = &make_filename_gz($self, $key);
 	my $compressdata=Nana::GZIP::gzipcompress($value);
 	Nana::File::lock_delete($filename);
 	return Nana::File::lock_store($filename_gz, $compressdata);
@@ -64,29 +64,28 @@
 # Fetch												# comment
 sub FETCH {
 	my ($self, $key) = @_;
-	my $filename = &make_filename($self, $key);
-	my $filename_gz = &make_filename_gz($self, $key);
+	my ($mode, $filename) = &make_filename($self, $key);
+	my ($mode, $filename_gz) = &make_filename_gz($self, $key);
 	if(-e $filename_gz) {
+		return (stat($filename_gz))[9] if($mode eq "update");
 		my $data=Nana::File::lock_fetch($filename_gz);
 		return Nana::GZIP::gzipuncompress($data);
 	}
+	return (stat($filename))[9] if($mode eq "update");
 	return Nana::File::lock_fetch($filename);
 }
 
 # Exists											# comment
 sub EXISTS {
 	my ($self, $key) = @_;
-	my $filename = &make_filename($self, $key);
-	my $filename_gz = &make_filename_gz($self, $key);
-	if (-e $filename) {
-		return 1;
-	} elsif(-e $filename_gz) {
-		return 1;
-	}
+	my ($mode, $filename) = &make_filename($self, $key);
+	my ($mode, $filename_gz) = &make_filename_gz($self, $key);
+	return 1 if (-e $filename);
+	return 1 if (-e $filename_gz);
 	return 0;
 }
 
-# Delete
+# Delete											# comment
 sub DELETE {
 	my ($self, $key) = @_;
 	my $filename = &make_filename($self, $key);
@@ -120,16 +119,23 @@
 
 sub make_filename {
 	my ($self, $key) = @_;
+	my $mode="";
+	if($key=~/^\_\_(.+?)\_\_(.+?)$/) {
+		$mode=$1;
+		$key=$2;
+	}
 	$key =~ s/(.)/$::_dbmname_encode{$1}/g;
-
 	return $self->{dir} . "/$key.txt";
 }
 
 sub make_filename_gz {
 	my ($self, $key) = @_;
+	my $mode="";
+	if($key=~/^\_\_(.+?)\_\_(.+?)$/) {
+		$mode=$1;
+		$key=$2;
+	}
 	$key =~ s/(.)/$::_dbmname_encode{$1}/g;
-
 	return $self->{dir} . "/$key.txt.gz";
 }
-
 1;



Pyukiwiki-cvs メーリングリストの案内
Back to archive index