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

Hotfix/check permissions before chmod #212

Merged

Conversation

Gautzilla
Copy link
Contributor

This PR should fix a bug where OSEkit unnecessarily tries to change folders/files for which it already has write/read accesses but for which it doesn't have the permission to change the permissions.

Basically, the os.chmod function should now only be called if the user doesn't have the read and write permissions to the file or folder.

@cazaudo: In the Spectrogram class, 2 files permissions were changed to the DPDEFAULT mode:
Line 1050

if not filename.exists():
  pd.DataFrame.from_records([new_params]).to_csv(filename, index=False)  
  os.chmod(filename, mode=DPDEFAULT)
  return True

Line 1065

filename.unlink()
pd.DataFrame.from_records([new_params]).to_csv(filename, index=False)
os.chmod(filename, mode=DPDEFAULT)
return True

I changed the modes to FPDEFAULT, and added a comment to keep track of that:

if not filename.exists():
  pd.DataFrame.from_records([new_params]).to_csv(filename, index=False)
  chmod_if_needed(
      path=filename, mode=FPDEFAULT
  )  # This was DPDEFAULT: was it intentional?
  return True

I'll remove the comment if you validate that the mode should be FPDEFAULT, or change back to DPDEFAULT

@Gautzilla Gautzilla self-assigned this Oct 18, 2024
@Gautzilla Gautzilla linked an issue Oct 18, 2024 that may be closed by this pull request
@Gautzilla Gautzilla merged commit c527c9f into Project-OSmOSE:main Oct 18, 2024
1 check passed
@Gautzilla Gautzilla deleted the hotfix/check-permissions-before-chmod branch October 18, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dataset build not working when not proprietary of audio files
2 participants