0

I have a Ruby script written by someone else that creates hard links for files located in the main folder, placing them into the subfolder using:

File.link('/mnt/server10/file1.lzo', '/mnt/server10/subfolder10/file2.lzo')

I have 10 identical Windows servers' shares mounted on the Linux server and 9 out of 10 mount points have no issues with the above command. However, one mount point is having an issue with the above command and generates the following error:

Hardlink failed: No such file or directory - /mnt/server10/file1.lzo or /mnt/server10/subfolder10/file1.lzo

I have no problem creating the link manually:

ln /mnt/server10/file1.lzo  /mnt/server10/subfolder10/file1.lzo

All permissions and settings are identical.

The Ruby script that creates hard links is the same for all mount points. The mount points have identical permissions on the Linux and Windows sides.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
browser30
  • 61
  • 2
  • 7
  • 1
    Please use formatting to make your text more easily read. This helps others understand the question. – the Tin Man Aug 17 '16 at 19:39
  • This doesn't sound like a Ruby problem if the code is the same and it works for most of the cases. I'd look for differences between the Windows servers. [su] is probably a better site to ask this on as it sounds like an OS-related problem. – the Tin Man Aug 17 '16 at 19:44

1 Answers1

0

The bash 'ln' command seems to create the required subfolders by itself. in ruby you have to do it yourself. There is a nice gem called 'rake' which provides the pathmap method for strings, directory and filenames.

Before creating a hardlink you can have to create the subdirectory first:

require 'rake'
def create_parent_dirs_for(filename)
  mkdir_p filename.pathmap('%d')
end

Further reading and watching: http://www.virtuouscode.com/2014/04/24/rake-part-4-pathmap/