Skip to content

Commit

Permalink
Fix symlink name on duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Mar 28, 2022
1 parent 9460d48 commit 7a16383
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions extensions/file-manager/create_symlink.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ if (!@entries_list) {
foreach my $name (@entries_list) {
my $name_ = $name;
$name = simplify_path($name);
my $symlink = "$cwd/${name}_symlink";
my $symlink = "$cwd/${name}--symlink";

# If symlink exists add a numerable suffix
if (-e $symlink) {
$symlink .= "_" . int(rand() * 10000);
my $__ = 1;
for (;;) {
my $necwd = "$symlink(" . $__++ . ")";
if (!-e $necwd) {
$symlink = $necwd;
last;
}
}
}

if (symlink_file("$cwd/$name", $symlink) == 0) {
$error .= "<br>" if ($error);
$error .= text('filemanager_symlink_exists', html_escape("${name_}_symlink"), html_escape($cwd));
Expand Down

0 comments on commit 7a16383

Please sign in to comment.