some filesystems are case insensitive, always use case insensitive lookup
This commit is contained in:
parent
7ec42cab8d
commit
643e2e587e
2 changed files with 13 additions and 2 deletions
|
@ -732,7 +732,7 @@ class File(db.Model):
|
||||||
|
|
||||||
def move(self):
|
def move(self):
|
||||||
def format_underscores(string):
|
def format_underscores(string):
|
||||||
return re.sub(r'^\.|\.$|:|/|\?|<|>|\\|\*', '_', string)
|
return re.sub(r'^\.|\.$|:|/|\?|<|>|\\|\*|\||"', '_', string)
|
||||||
prefs = settings.preferences
|
prefs = settings.preferences
|
||||||
prefix = os.sep.join(os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/').split('/'))
|
prefix = os.sep.join(os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/').split('/'))
|
||||||
if not self.item:
|
if not self.item:
|
||||||
|
@ -779,7 +779,7 @@ class File(db.Model):
|
||||||
if self.path == new_path:
|
if self.path == new_path:
|
||||||
return
|
return
|
||||||
h = ''
|
h = ''
|
||||||
while os.path.exists(os.path.join(prefix, new_path)):
|
while utils.iexists(os.path.join(prefix, new_path)):
|
||||||
h = self.sha1[:len(h)+1]
|
h = self.sha1[:len(h)+1]
|
||||||
filename = '%s.%s.%s' % (title, h, extension)
|
filename = '%s.%s.%s' % (title, h, extension)
|
||||||
first = unicodedata.normalize('NFD', author[0].upper())[0].upper()
|
first = unicodedata.normalize('NFD', author[0].upper())[0].upper()
|
||||||
|
|
11
oml/utils.py
11
oml/utils.py
|
@ -440,3 +440,14 @@ def send_debug():
|
||||||
settings.server['last_debug'] = timestamp
|
settings.server['last_debug'] = timestamp
|
||||||
except:
|
except:
|
||||||
logger.debug('failed to send debug information')
|
logger.debug('failed to send debug information')
|
||||||
|
|
||||||
|
def iexists(path):
|
||||||
|
parts = path.split(os.sep)
|
||||||
|
name = parts[-1].lower()
|
||||||
|
if len(parts) == 1:
|
||||||
|
folder = '.'
|
||||||
|
else:
|
||||||
|
folder = os.path.dirname(path)
|
||||||
|
files = os.listdir(folder)
|
||||||
|
files = {os.path.basename(f).lower() for f in files}
|
||||||
|
return name in files
|
||||||
|
|
Loading…
Reference in a new issue