Get help, report and discuss bugs.
-
KaraokeStu
- Posts: 39
- Joined: 17 Sep 2008, 20:01
Post
by KaraokeStu » 15 Oct 2008, 00:11
I'm hoping the author is available to look at a bug within the code.
If the directory it tries to move the files to already exists, it does not work.
I beleive at the moment it simply tries to move the entire directory to the destination.
What it should do is check to see the directory exists at the destination.
If it does, then it needs to move the files to that directory.
If not, then it needs to create the directory and then move the contents over.
Once this is done, it should be then safe to remove the source directory (provided it is empty)
-
ydrol
- Posts: 33
- Joined: 03 Oct 2008, 11:34
Post
by ydrol » 16 Oct 2008, 20:35
Hi, I'll look at this soon. V busy at work at the moment.
-
KaraokeStu
- Posts: 39
- Joined: 17 Sep 2008, 20:01
Post
by KaraokeStu » 04 Dec 2008, 08:22
Hi,
I managed to work it out for myself:
Code: Select all
sub relocate() {
my $new_parent_dir = $defaultCompletedFolder;
if (defined($category) && $category ne "" ){
# Check for Category Alternate Path
if (exists($completedFoldersByCategory{$category})) {
$new_parent_dir=$completedFoldersByCategory{$category};
} elsif (defined($new_parent_dir) && $new_parent_dir ne "" ){
# Use default Category Path
$new_parent_dir = "$new_parent_dir/$category";
}
}
if (defined($new_parent_dir) && $new_parent_dir ne "" ){
# Make path Absolute
if ($new_parent_dir !~ /^\// ) {
$new_parent_dir = $NZBCFG{destdir}."/$new_parent_dir";
}
#Split destination directory into its relevant parts
my $old_parent_dir=dirname($destDir);
my $b=basename($destDir);
if (system("test \"$old_parent_dir\" -ef \"$new_parent_dir\"") != 0) {
#Test to see if the destination dir already exists
if(-d "$new_parent_dir/$b")
{
#The directory already exists, so move our files from our source dir to the destination dir, then delete the original folder
info("Moving files from $destDir to existing directory $new_parent_dir/$b");
move("$destDir/*","$new_parent_dir/$b");
rmdir($destDir);
} elsif (runCommand("mkdir -p \"$new_parent_dir\"") == 0) {
#The new directory doesn't already exist, so make sure the new parent exists and then move the directory as a whole
info("Moving $destDir to $new_parent_dir");
move($destDir,"$new_parent_dir/$b");
}
}
}
}
-
ydrol
- Posts: 33
- Joined: 03 Oct 2008, 11:34
Post
by ydrol » 04 Dec 2008, 13:08
Glad you got it sorted. Sorry I couldn't help sooner.
-
KaraokeStu
- Posts: 39
- Joined: 17 Sep 2008, 20:01
Post
by KaraokeStu » 10 Dec 2008, 14:26
After further testing, the code I've used doesn't work.
Could you have a look at the code here:
Code: Select all
move("$destDir/*","$new_parent_dir/$b");
rmdir($destDir);
And tell me why its not working?
I'm not great with Perl, but it is getting as far as realising the directory already exists
-
KaraokeStu
- Posts: 39
- Joined: 17 Sep 2008, 20:01
Post
by KaraokeStu » 10 Dec 2008, 14:30
PS: I think it should be working ok, as the output is as follows:
PostProc:Moving files from /mnt/disk1/nzbget/dst/Video/TV/The IT Crowd to existing directory /mnt/disk1/share/Video/TV/The IT Crowd
Who is online
Users browsing this forum: No registered users and 55 guests