mirror of
https://github.com/beetbox/beets.git
synced 2025-12-31 04:52:49 +01:00
plugin now listens for item_copied instead of after_write. now the test works
This commit is contained in:
parent
a01e73d813
commit
8784e8d8ca
2 changed files with 11 additions and 8 deletions
|
|
@ -35,8 +35,8 @@ class Permissions(BeetsPlugin):
|
|||
})
|
||||
|
||||
|
||||
@Permissions.listen('after_write')
|
||||
def permissions(path):
|
||||
@Permissions.listen('item_copied')
|
||||
def permissions(item, source, destination):
|
||||
"""Running the permission fixer.
|
||||
"""
|
||||
# Getting the config.
|
||||
|
|
@ -45,10 +45,11 @@ def permissions(path):
|
|||
# Converts file permissions to oct.
|
||||
file_perm = convert_perm(file_perm)
|
||||
|
||||
# Changing permissions on the path.
|
||||
os.chmod(util.bytestring_path(path), file_perm)
|
||||
# Changing permissions on the destination path.
|
||||
os.chmod(util.bytestring_path(destination), file_perm)
|
||||
|
||||
# Checks if the path has the permissions configured.
|
||||
if not check_permissions(util.bytestring_path(path), file_perm):
|
||||
message = 'There was a problem setting permission on {}'.format(path)
|
||||
# Checks if the destination path has the permissions configured.
|
||||
if not check_permissions(util.bytestring_path(destination), file_perm):
|
||||
message = 'There was a problem setting permission on {}'.format(
|
||||
destination)
|
||||
print(message)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
"""Tests for the 'permissions' plugin.
|
||||
"""
|
||||
from _common import unittest
|
||||
from helper import TestHelper
|
||||
from beetsplug.permissions import check_permissions, convert_perm
|
||||
|
|
@ -22,7 +24,7 @@ class PermissionsPluginTest(unittest.TestCase, TestHelper):
|
|||
config_perm = self.config['permissions']['file'].get()
|
||||
config_perm = convert_perm(config_perm)
|
||||
|
||||
assert check_permissions(item.path, config_perm)
|
||||
self.assertTrue(check_permissions(item.path, config_perm))
|
||||
|
||||
|
||||
def suite():
|
||||
|
|
|
|||
Loading…
Reference in a new issue