Custom shortcut directory

Dear Ondemand Hive,

We have custom directories managed with acl.

As it’s not concerning each users, /etc/ood/config/apps/dashboard/initializers/ood.rb is not the good place to define it.

Is it possible to add shorcut by defining them in our personnal dashboad (as user) ? (in $HOME/ondemand/ for example )

Thank

I don’t believe so. But even so, if the directories are manged by ACLs you can simply use the readable? API on Pathname and only add it if it’s indeed readable (you may also need executable?anddirectory?` to be extra double sure it’s valid).

https://docs.ruby-lang.org/en/master/File/Stat.html#method-i-readable-3F

1 Like

Hi @jeff.ohrstrom

Thank a lot it’s working,

Here my code if it’s can help, you can delete the scratch block and fix the base_paths.

# /etc/ood/config/apps/dashboard/initializers/ood.rb

Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|

    # Add User scratch space directory
    user = User.new.name
    first_letter = user[0] # Get the first letter of the username
    scratch_path = "/srv/beegfs/scratch/users/#{first_letter}/#{user}"
    paths << FavoritePath.new(scratch_path, title: "Scratch Directory")

    # Hash of base paths to check for additional directories with titles
    # location => Title
    base_paths = {
      '/home/share/' => 'Shared home',
      '/srv/beegfs/scratch/shares/' => 'Shared scratch',
      '/srv/beegfs/scratch/groups/' => 'Group scratch',
      '/srv/fast/users/' => 'Fast user'
      # Add more paths and titles here if needed
    }

    base_paths.each do |base_path, title|

      # Check if the base path exists and is a directory,  to avoid error
      next unless Dir.exist?(base_path)

      # Get all entries in the current base path
      Dir.entries(base_path).each do |entry|
        # Construct the full path for the current entry
        full_path = File.join(base_path, entry)

        # Skip if it's not a directory or if it's a special entry like '.' or '..'
        next unless File.directory?(full_path) && !['.', '..'].include?(entry)

        # Check if the directory is readable and executable
        if File.readable?(full_path) && File.executable?(full_path)
          # Access the value of the current base_path using the `title` variable
          paths << FavoritePath.new(full_path, title: "#{title}: #{File.basename(full_path)}")
        end
      end
    end
  end
end

Maybe this block could be add in the documentation ?
I have created a new PR: