mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Merge branch 'add_sanitize_callback' of https://github.com/comutt/calibre
This commit is contained in:
commit
ac0969ae17
@ -1015,6 +1015,13 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
|
||||
return path
|
||||
|
||||
def sanitize_callback(self, path):
|
||||
'''
|
||||
Callback to allow individual device drivers to override the path sanitization
|
||||
used by :meth:`create_upload_path`.
|
||||
'''
|
||||
return sanitize(path)
|
||||
|
||||
def filename_callback(self, default, mi):
|
||||
'''
|
||||
Callback to allow drivers to change the default file name
|
||||
@ -1044,7 +1051,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
def create_upload_path(self, path, mdata, fname, create_dirs=True):
|
||||
from calibre.devices.utils import create_upload_path
|
||||
settings = self.settings()
|
||||
filepath = create_upload_path(mdata, fname, self.save_template(), sanitize,
|
||||
filepath = create_upload_path(mdata, fname, self.save_template(), self.sanitize_callback,
|
||||
prefix_path=os.path.abspath(path),
|
||||
maxlen=self.MAX_PATH_LEN,
|
||||
use_subdirs = self.SUPPORTS_SUB_DIRS and settings.use_subdirs,
|
||||
|
@ -99,7 +99,8 @@ def create_upload_path(mdata, fname, template, sanitize,
|
||||
app_id = str(getattr(mdata, 'application_id', ''))
|
||||
id_ = mdata.get('id', fname)
|
||||
extra_components = get_components(template, mdata, id_,
|
||||
timefmt=opts.send_timefmt, length=maxlen-len(app_id)-1)
|
||||
timefmt=opts.send_timefmt, length=maxlen-len(app_id)-1,
|
||||
sanitize_func=sanitize)
|
||||
if not extra_components:
|
||||
extra_components.append(sanitize(filename_callback(fname,
|
||||
mdata)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user