tweak relativise
[id3fs.git] / lib / ID3FS / DB.pm
index fced79e..955e117 100644 (file)
@@ -23,11 +23,11 @@ sub new
     $self->{base}=shift;
     my $fallbackdir=shift;
 
-    $dbpath=$self->find_db($init, $dbpath, $fallbackdir);
-    return undef unless($dbpath);
+    $self->{dbpath}=$self->find_db($init, $dbpath, $fallbackdir);
+    return undef unless($self->{dbpath});
     $self->{absbase}=Cwd::abs_path($self->{base});
 
-    my $connectstr="dbi:SQLite:dbname=$dbpath";
+    my $connectstr="dbi:SQLite:dbname=$self->{dbpath}";
     my ($user, $pass)=("", "");
     if($self->{postgres})
     {
@@ -35,7 +35,7 @@ sub new
        $user="ianb";
        $pass="foo";
     }
-    my $exists=-f $dbpath;
+    my $exists=-f $self->{dbpath};
     $self->{dbh}=DBI->connect($connectstr, $user, $pass,
                              { AutoCommit=>1 } );
     unless(defined($self->{dbh}))
@@ -207,7 +207,8 @@ sub tag_has_values
 
 sub relativise
 {
-    my($self, $path, $name, $mountpoint, $id3fs_path)=@_;
+    my($self, $path, $name, $mountpoint)=@_;
+    my $id3fs_path=$self->{dbpath};
     $id3fs_path=~s/(.*)\/.*/$1/;
     my $rpath="$self->{absbase}/$path";
     my $vpath="$mountpoint/$id3fs_path";