Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions plugin: change permissions of folders #1308

Closed
l-t-k opened this issue Feb 4, 2015 · 5 comments
Closed

Permissions plugin: change permissions of folders #1308

l-t-k opened this issue Feb 4, 2015 · 5 comments
Assignees
Labels
feature features we would like to implement

Comments

@l-t-k
Copy link
Contributor

l-t-k commented Feb 4, 2015

Would be great if the permissions plugin can be used to change the permissions of the created folders as well.

@l-t-k l-t-k closed this as completed Feb 4, 2015
@l-t-k l-t-k reopened this Feb 4, 2015
@sampsyo sampsyo added the feature features we would like to implement label Feb 4, 2015
@xsteadfastx
Copy link
Collaborator

yeah cool idea. i dont have time today but will look into that in the next days :)

@xsteadfastx
Copy link
Collaborator

im kind of stuck in some design descisions. i cant find a fitting listener for that case. i could just chmod the album directory after they get imported. but that would miss the artist directory. mh. i will see

@xsteadfastx
Copy link
Collaborator

i could do some stuff with os.path.split... but i would just always get the directory the tracks are in... not the artist folder for example.

this was my first try to get a list of directories where i should run chmod on.... but the main problem is with my differential_path_list: if album and artist have the same name... its not working.

def get_music_directories(music_directory, imported_item):                        
      """Creates a list of directories the imported item is in.                     
      """                                                                           
      # Checks for the directory in config and if it has a tilde in it.             
      # If its that way it will be expanded to the full path.                       
      if '~' in music_directory:                                                    
          music_directory = os.path.expanduser(music_directory)                     

      # Getting the absolute path of the directory.                                 
      music_directory = os.path.abspath(music_directory)                            

      # Creates a differential path list of the directory config path and           
      # the path of the imported item.                                              
      differential_path_list = list(                                                
          set(os.path.split(imported_item)[0].split('/')) -                         
          set(music_directory.split('/')))                                          

      # Creating a list with full paths of all directories in the music library  
      # we need to look at for chaning permissions.                                 
      directory_list = []                                                           
      for path in differential_path_list:                                           
          if len(directory_list) > 0:                                               
              directory_list.append(os.path.join(directory_list[-1], path))         
          else:                                                                     
              directory_list.append(os.path.join(music_directory, path))            

      return directory_list                           

@sampsyo
Copy link
Member

sampsyo commented Feb 10, 2015

Perhaps just chmod all of the ancestors of the file, recursively, stopping when the change is disallowed? There's a utility in beets.util that can give you the ancestors.

The pruning logic there is another example of "bubbling up" until we hit the top library directory.

@xsteadfastx
Copy link
Collaborator

thats what i was thinking. i wrote my own "walker" for the directories. i just want to change permissions on directories in the library. what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature features we would like to implement
Projects
None yet
Development

No branches or pull requests

3 participants