[Tkabber-dev] r1113 - in trunk/tkabber: . plugins/chat

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Apr 15 10:31:07 MSD 2007


Author: sergei
Date: 2007-04-15 10:31:06 +0400 (Sun, 15 Apr 2007)
New Revision: 1113

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/chat/logger.tcl
Log:
	* plugins/chat/logger.tcl: Fixed bug with cinverting chatlogs
	  directory if its definition contains trailing slash.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-04-13 20:38:49 UTC (rev 1112)
+++ trunk/tkabber/ChangeLog	2007-04-15 06:31:06 UTC (rev 1113)
@@ -1,3 +1,8 @@
+2007-04-15  Sergei Golovan  <sgolovan at nes.ru>
+
+	* plugins/chat/logger.tcl: Fixed bug with cinverting chatlogs
+	  directory if its definition contains trailing slash.
+
 2007-04-13  Sergei Golovan  <sgolovan at nes.ru>
 
 	* pixmaps/default-blue/docking/tkabber.ico,

Modified: trunk/tkabber/plugins/chat/logger.tcl
===================================================================
--- trunk/tkabber/plugins/chat/logger.tcl	2007-04-13 20:38:49 UTC (rev 1112)
+++ trunk/tkabber/plugins/chat/logger.tcl	2007-04-15 06:31:06 UTC (rev 1113)
@@ -866,10 +866,20 @@
 	if {$v >= $version} return
     }
 
+    set parent_dir [file dirname $options(logdir)]
+    set log_dir [file tail $options(logdir)]
+
+    if {$log_dir == ""} {
+	return -code error \
+	       [::msgcat::mc "You're using root directory %s for storing Tkabber\
+			      logs!\n\nI refuse to convert logs database." \
+			     $options(logdir)]
+    }
+
     # Create temporary directory for converted logs
-    set dir "$options(logdir).new"
-    while {[file exists $dir]} {
-	set dir "$dir~"
+    set dir $log_dir.new
+    while {[file exists [file join $parent_dir $dir]]} {
+	set dir $dir~
     }
 
     set w .log_convert
@@ -900,21 +910,22 @@
     $w draw
     grab $w
 
-    convert_logs $t $options(logdir) $dir
+    convert_logs $t $options(logdir) [file join $parent_dir $dir]
     
-    set bdir "$options(logdir)~"
-    while {[file exists $bdir]} {
-	set bdir "$bdir~"
+    set bdir $log_dir~
+    while {[file exists [file join $parent_dir $bdir]]} {
+	set bdir $bdir~
     }
-    file rename -- $options(logdir) $bdir
-    file rename -- $dir $options(logdir)
+    file rename -- $options(logdir) [file join $parent_dir $bdir]
+    file rename -- [file join $parent_dir $dir] $options(logdir)
 
     if {[winfo exists $w]} {
 	$w itemconfigure 0 -state normal
 
 	$msg configure -text [::msgcat::mc "Chats history is converted.\nBackup\
 					    of the old history\
-					    is stored in %s" $bdir]
+					    is stored in %s" \
+					   [file join $parent_dir $bdir]]
 
 	$t configure -state normal
 	$t insert end "[::msgcat::mc {Conversion is finished}]\n"



More information about the Tkabber-dev mailing list