aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andy@smile.org.ua>2008-08-31 20:34:12 +0000
committerAndy Shevchenko <andy@smile.org.ua>2008-08-31 20:34:12 +0000
commitf2e6da73822bb5c85bbcf13d8f8592f59f3cb33c (patch)
treeae40f2c87c7715ca8f8b1452fe7e6ad46203c50e
parent69ba7ccff6d3336589e0bb9a84c5e70728a13dd1 (diff)
downloadrenrot-f2e6da73822bb5c85bbcf13d8f8592f59f3cb33c.tar.gz
renrot-f2e6da73822bb5c85bbcf13d8f8592f59f3cb33c.tar.bz2
git-svn-id: file:///svnroot/renrot/branches/andy@557 fe2816f4-e837-0410-b10a-f608c9d244a1
-rwxr-xr-xrenrot65
1 files changed, 27 insertions, 38 deletions
diff --git a/renrot b/renrot
index 32d0d0c..13ff87e 100755
--- a/renrot
+++ b/renrot
@@ -1143,6 +1143,7 @@ sub aggregationProcess {
my $counterSize = shift;
my $file;
my $info;
+ my $BaseDir;
my $NewDir;
my $file_num = scalar(keys(%filenameshash));
my $file_rem = 0;
@@ -1150,13 +1151,18 @@ sub aggregationProcess {
procmsg ("AGGREGATION\n");
procmsg ("===========\n");
+ if ($cfgOpts{'aggregation virtual'} == 0) {
+ $BaseDir = $cfgOpts{'aggregation directory'};
+ } else {
+ $BaseDir = $cfgOpts{'aggregation virtual directory'};
+ }
+
if ($cfgOpts{'aggregation mode'} eq "template") {
dbgmsg (1, "Template: $cfgOpts{'aggregation template'}\n");
my $fileCounter = $countStart;
foreach $file (sort (keys %filenameshash)) {
$file_rem++;
- dbgmsg (4, "Processing ($file_rem of $file_num) file: $file\n");
$info = $exifToolObj->ImageInfo($file);
$NewDir = template2name (
$exifToolObj,
@@ -1167,8 +1173,8 @@ sub aggregationProcess {
$counterSize,
"0cw"
);
+ $NewDir = File::Spec->catdir($BaseDir, $NewDir);
aggregateFile($file, $NewDir) if ($dryRun == 0);
-
procmsg ("Aggregate: ($file_rem of $file_num) $file -> $NewDir\n", "\n");
$fileCounter += $countStep;
}
@@ -1181,18 +1187,17 @@ sub aggregationProcess {
foreach $file (sort (keys %filenameshash)) {
$filetmp = $file;
$file_rem++;
- dbgmsg (4, "Processing ($file_rem of $file_num) file: $file\n");
if ($DirCounter == 1) {
$timestampPrev = $filenameshash{$filetmp};
$filePrev = $filetmp;
- $NewDir = $cfgOpts{'aggregation directory'} . "." . sprintf($counterSize, $DirCounter);
+ $NewDir = $BaseDir . "." . sprintf($counterSize, $DirCounter);
$DirCounter++;
aggregateFile($file, $NewDir) if ($dryRun == 0);
} else {
# Check for new direcroty creation
if (($filenameshash{$filetmp} - $timestampPrev) > $cfgOpts{'aggregation delta'}) {
- $NewDir = $cfgOpts{'aggregation directory'} . "." . sprintf($counterSize, $DirCounter);
+ $NewDir = $BaseDir . "." . sprintf($counterSize, $DirCounter);
$DirCounter++;
}
aggregateFile($file, $NewDir) if ($dryRun == 0);
@@ -1670,41 +1675,23 @@ sub makeDir {
sub aggregateFile {
my $file = shift;
my $new_dir = shift;
+ my ($dummy_volume, $dummy_dir, $base_name) = File::Spec->splitpath($file);
+
+ makeDir($new_dir);
if ($cfgOpts{'aggregation virtual'} == 0) {
- makeDir($cfgOpts{'aggregation directory'});
- $new_dir = File::Spec->catdir($cfgOpts{'aggregation directory'}, $new_dir);
- makeDir($new_dir);
- my $newname = File::Spec->catfile($new_dir, $file);
- rename ($file, $newname) || ( fatalmsg ("While moving $file -> $newname, perhaps new directory is at different file system\n"), die );
+ my $newname = File::Spec->catfile($new_dir, $base_name);
+ rename ($file, $newname) || ( fatalmsg ("While moving $file -> $newname, perhaps a different file system is using\n"), die );
dbgmsg (3, "$file moved to $newname\n");
} else {
- makeDir($cfgOpts{'aggregation virtual directory'});
- $new_dir = File::Spec->catdir($cfgOpts{'aggregation virtual directory'}, $new_dir);
- makeDir($new_dir);
- my $newfile = File::Spec->catfile($new_dir, $file);
-
- my @virt_dir = split(/\//, $cfgOpts{'aggregation virtual directory'});
-
- use Cwd;
- my @cwd = split(/\//, getcwd());
- my $i = 0;
-
- my $oldfile = "../../"; # since the aggregat is placed @ the 'aggr virt dir' and the 'aggr mode' caused dir
- while ($virt_dir[$i] eq "..") { # how many levels '..' the aggregat have to be placed uper than cwd
- $i++;
- }
-
- for ($i; $i > 0; $i--) { # aggregat path forming according the $i value
- $oldfile .= $cwd[scalar(@cwd) - $i] . "/";
- }
-
+ my $newfile = File::Spec->catfile(File::Spec->abs2rel($new_dir), $base_name);
if (not -l $newfile) {
- $oldfile .= $file;
+ # Make relative path to original file from new directory
+ my $oldfile = File::Spec->catfile(File::Spec->abs2rel(File::Spec->curdir(), $new_dir), $file);
symlink ($oldfile, $newfile) || ( fatalmsg ("While linking $oldfile -> $newfile\n"), die );
dbgmsg (3, "Following link was created $newfile -> $oldfile\n");
} else {
- procmsg ("Link $newfile already exists.\n");
+ warnmsg ("Link $newfile already exists.\n");
}
}
}
@@ -2578,13 +2565,14 @@ template.
Aggregation time delta, in seconds. Files with DateTimeOriginal and ones of
the previous file delta, greater than B<--aggr-delta> are placed in the
-directory, with the name constructed by concatenating the value of the
+directories, with the names are constructed by concatenating the value of the
B<--aggr-directory> option and the directory name counter.
=item B<--aggr-directory> F<DIR>
-Aggregation directory name prefix (default is I<Images>), have to be on the same
-file system, relative to the current working directory and contain no unexistent subdirectories.
+Aggregation directory name prefix (default is I<Images>), have to be on the
+same file system, relative to the current working directory or an absolute path
+and contain no unexistent subdirectories.
=item B<-a> or B<--aggr-template> I<TEMPLATE>
@@ -2608,9 +2596,10 @@ virtualization.
=item B<--aggr-virtual-directory> F<DIR>
-Virtual aggregation directory name prefix (default is I<Images.Links.Directory>),
-have to be on the same file system, relative to the current working directory and
-contain no unexistent subdirectories.
+Virtual aggregation directory name prefix (default is
+I<Images.Links.Directory>), have to be on the file system which is supported
+symbolic links, relative to the current working directory or an absolute path
+and contain no unexistent subdirectories.
=item B<--comment-file> F<FILE>

Return to:

Send suggestions and report system problems to the System administrator.