plugin now listens for item_copied instead of after_write. now the test works

This commit is contained in:
Marvin Steadfast 2014-11-20 11:40:02 +01:00
parent a01e73d813
commit 8784e8d8ca
2 changed files with 11 additions and 8 deletions

View file

@ -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)

View file

@ -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():