diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html
index a087b2af..3be397e2 100644
--- a/data/interfaces/default/config.html
+++ b/data/interfaces/default/config.html
@@ -685,6 +685,14 @@
+
+
+
+
+
+
+
+
diff --git a/headphones/__init__.py b/headphones/__init__.py
index 78803803..3959f1fc 100644
--- a/headphones/__init__.py
+++ b/headphones/__init__.py
@@ -197,6 +197,7 @@ DOWNLOAD_TORRENT_DIR = None
INTERFACE = None
FOLDER_PERMISSIONS = None
+FILE_PERMISSIONS = None
MUSIC_ENCODER = False
ENCODERFOLDER = None
@@ -304,7 +305,7 @@ def initialize():
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, HEADPHONES_INDEXER, NZBMATRIX, TRANSMISSION_HOST, TRANSMISSION_USERNAME, TRANSMISSION_PASSWORD, \
UTORRENT_HOST, UTORRENT_USERNAME, UTORRENT_PASSWORD, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS, \
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NZBSRUS, NZBSRUS_UID, NZBSRUS_APIKEY, NZB_DOWNLOADER, TORRENT_DOWNLOADER, PREFERRED_WORDS, REQUIRED_WORDS, IGNORED_WORDS, \
- LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, ENCODERFOLDER, ENCODER_PATH, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, \
+ LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, FILE_PERMISSIONS, ENCODERFOLDER, ENCODER_PATH, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, \
MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, \
PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, PUSHOVER_ENABLED, PUSHOVER_PRIORITY, PUSHOVER_KEYS, PUSHOVER_ONSNATCH, MIRRORLIST, \
MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \
@@ -470,6 +471,7 @@ def initialize():
INTERFACE = check_setting_str(CFG, 'General', 'interface', 'default')
FOLDER_PERMISSIONS = check_setting_str(CFG, 'General', 'folder_permissions', '0755')
+ FILE_PERMISSIONS = check_setting_str(CFG, 'General', 'file_permissions', '0644')
ENCODERFOLDER = check_setting_str(CFG, 'General', 'encoderfolder', '')
ENCODER_PATH = check_setting_str(CFG, 'General', 'encoder_path', '')
@@ -873,6 +875,7 @@ def config_write():
new_config['General']['lastfm_username'] = LASTFM_USERNAME
new_config['General']['interface'] = INTERFACE
new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS
+ new_config['General']['file_permissions'] = FILE_PERMISSIONS
new_config['General']['music_encoder'] = int(MUSIC_ENCODER)
new_config['General']['encoder'] = ENCODER
diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py
index 132ec931..ba61ef91 100644
--- a/headphones/postprocessor.py
+++ b/headphones/postprocessor.py
@@ -395,6 +395,8 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
else:
albumpaths = [albumpath]
+ updateFilePermissions(albumpaths)
+
myDB = db.DBConnection()
myDB.action('UPDATE albums SET status = "Downloaded" WHERE AlbumID=?', [albumid])
myDB.action('UPDATE snatched SET status = "Processed" WHERE AlbumID=?', [albumid])
@@ -860,7 +862,20 @@ def renameFiles(albumpath, downloaded_track_list, release):
except Exception, e:
logger.error('Error renaming file: %s. Error: %s' % (downloaded_track.decode(headphones.SYS_ENCODING, 'replace'), e))
continue
-
+
+def updateFilePermissions(albumpaths):
+
+ for folder in albumpaths:
+ logger.info("Updating file permissions in " + folder.decode(headphones.SYS_ENCODING, 'replace'))
+ for r,d,f in os.walk(folder):
+ for files in f:
+ full_path = os.path.join(r, files)
+ try:
+ os.chmod(full_path, int(headphones.FILE_PERMISSIONS))
+ except:
+ logger.error("Could not change permissions for file: " + full_path.decode(headphones.SYS_ENCODING, 'replace'))
+ continue
+
def renameUnprocessedFolder(albumpath):
i = 0
diff --git a/headphones/webserve.py b/headphones/webserve.py
index 1807409f..5aa452ef 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -696,7 +696,9 @@ class WebInterface(object):
"customsleep": headphones.CUSTOMSLEEP,
"hpuser": headphones.HPUSER,
"hppass": headphones.HPPASS,
- "cache_sizemb":headphones.CACHE_SIZEMB,
+ "cache_sizemb": headphones.CACHE_SIZEMB,
+ "file_permissions": headphones.FILE_PERMISSIONS,
+ "folder_permissions": headphones.FOLDER_PERMISSIONS
}
# Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8
@@ -731,7 +733,7 @@ class WebInterface(object):
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, synoindex_enabled=False,
pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, mirror=None, customhost=None, customport=None,
customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, cache_sizemb=None,
- enable_https=0, https_cert=None, https_key=None, **kwargs):
+ enable_https=0, https_cert=None, https_key=None, file_permissions=None, folder_permissions=None, **kwargs):
headphones.HTTP_HOST = http_host
headphones.HTTP_PORT = http_port
@@ -860,6 +862,8 @@ class WebInterface(object):
headphones.HPUSER = hpuser
headphones.HPPASS = hppass
headphones.CACHE_SIZEMB = int(cache_sizemb)
+ headphones.FILE_PERMISSIONS = file_permissions
+ headphones.FOLDER_PERMISSIONS = folder_permissions
# Handle the variable config options. Note - keys with False values aren't getting passed