mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Calibre portable: Do not allow calibre portable to run if it is placed in a location whose path is too long. Also hide the library location setup in the welcome wizard when running the portable build.
This commit is contained in:
parent
9df6413df5
commit
f8c70eccde
@ -53,7 +53,7 @@ void show_last_error(LPCTSTR preamble) {
|
||||
NULL,
|
||||
dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
&msg,
|
||||
(LPTSTR)&msg,
|
||||
0, NULL );
|
||||
|
||||
show_detailed_error(preamble, msg, (int)dw);
|
||||
@ -136,7 +136,7 @@ void launch_calibre(LPCTSTR exe, LPCTSTR config_dir, LPCTSTR library_dir) {
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||
{
|
||||
LPTSTR app_dir, config_dir, exe, library_dir;
|
||||
LPTSTR app_dir, config_dir, exe, library_dir, too_long;
|
||||
|
||||
app_dir = get_app_dir();
|
||||
config_dir = (LPTSTR)calloc(BUFSIZE, sizeof(TCHAR));
|
||||
@ -147,7 +147,15 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||
_sntprintf_s(exe, BUFSIZE, _TRUNCATE, _T("%sCalibre\\calibre.exe"), app_dir);
|
||||
_sntprintf_s(library_dir, BUFSIZE, _TRUNCATE, _T("%sCalibre Library"), app_dir);
|
||||
|
||||
launch_calibre(exe, config_dir, library_dir);
|
||||
if ( _tcscnlen(library_dir, BUFSIZE) <= 74 ) {
|
||||
launch_calibre(exe, config_dir, library_dir);
|
||||
} else {
|
||||
too_long = (LPTSTR)calloc(BUFSIZE+300, sizeof(TCHAR));
|
||||
_sntprintf_s(too_long, BUFSIZE+300, _TRUNCATE,
|
||||
_T("Path to Calibre Portable (%s) too long. Must be less than 59 characters."), app_dir);
|
||||
|
||||
show_error(too_long);
|
||||
}
|
||||
|
||||
free(app_dir); free(config_dir); free(exe); free(library_dir);
|
||||
|
||||
|
@ -16,7 +16,8 @@ from PyQt4.Qt import (QWizard, QWizardPage, QPixmap, Qt, QAbstractListModel,
|
||||
from calibre import __appname__, patheq
|
||||
from calibre.library.database2 import LibraryDatabase2
|
||||
from calibre.library.move import MoveLibrary
|
||||
from calibre.constants import filesystem_encoding, iswindows, plugins
|
||||
from calibre.constants import (filesystem_encoding, iswindows, plugins,
|
||||
isportable)
|
||||
from calibre.gui2.wizard.send_email import smtp_prefs
|
||||
from calibre.gui2.wizard.device_ui import Ui_WizardPage as DeviceUI
|
||||
from calibre.gui2.wizard.library_ui import Ui_WizardPage as LibraryUI
|
||||
@ -769,6 +770,10 @@ class LibraryPage(QWizardPage, LibraryUI):
|
||||
traceback.print_exc()
|
||||
lp = os.path.expanduser(u'~')
|
||||
self.location.setText(lp)
|
||||
# Hide the library location settings if we are a portable install
|
||||
for x in ('location', 'button_change', 'libloc_label1',
|
||||
'libloc_label2'):
|
||||
getattr(self, x).setVisible(not isportable)
|
||||
|
||||
def isComplete(self):
|
||||
try:
|
||||
|
@ -34,7 +34,7 @@
|
||||
<widget class="QComboBox" name="language"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="libloc_label1">
|
||||
<property name="text">
|
||||
<string><p>Choose a location for your books. When you add books to calibre, they will be copied here. Use an <b>empty folder</b> for a new calibre library:</string>
|
||||
</property>
|
||||
@ -58,7 +58,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<widget class="QLabel" name="libloc_label2">
|
||||
<property name="text">
|
||||
<string>If you have an existing calibre library, it will be copied to the new location. If a calibre library already exists at the new location, calibre will switch to using it.</string>
|
||||
</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user