Compare commits

..

No commits in common. "f8d226a3dede8d52dbb144389c0986625d3c0fa3" and "74e89693ffa88ce054d598cc3fbcf7fbb088fdc8" have entirely different histories.

5 changed files with 48 additions and 53 deletions

View file

@ -134,7 +134,7 @@ def command_postupdate(*args):
print('usage: -o oldversion -n newversion')
sys.exit(1)
if old <= '20140521-65-e14c686' and new > '20140521-65-e14c686':
if not os.path.exists(settings.db_path) and sys.platform != 'win32':
if not os.path.exists(settings.db_path):
r('./ctl', 'setup')
import setup
setup.upgrade_db(old, new)

View file

@ -30,10 +30,7 @@ class Icons(dict):
def is_available(self):
folder = os.path.dirname(self._db)
base = os.path.dirname(os.path.dirname(folder))
if os.path.exists(base):
if not os.path.exists(folder):
ox.makedirs(folder)
if os.path.exists(folder):
if not os.path.exists(self._db):
self.create()
return os.path.exists(self._db)
@ -140,7 +137,7 @@ def get_icons_db_path():
import settings
import shutil
library = os.path.normpath(os.path.expanduser(settings.preferences['libraryPath']))
library = os.path.expanduser(settings.preferences['libraryPath'])
metadata = os.path.join(library, 'Metadata')
icons_db_path = os.path.join(metadata, 'icons.db')
if os.path.exists(os.path.dirname(library)):

View file

@ -34,7 +34,7 @@ def api_requestPeering(user_id, username, message):
return False
def api_acceptPeering(user_id, username, message):
user = User.get(user_id, for_update=True)
user = User.get(user_id)
if user:
logger.debug('incoming acceptPeering event: pending: %s', user.pending)
if user.pending == 'sent':
@ -50,7 +50,7 @@ def api_acceptPeering(user_id, username, message):
return False
def api_rejectPeering(user_id, message):
user = User.get(user_id, for_update=True)
user = User.get(user_id)
if user:
user.info['message'] = message
user.update_peering(False)
@ -59,7 +59,7 @@ def api_rejectPeering(user_id, message):
return False
def api_removePeering(user_id, message):
user = User.get(user_id, for_update=True)
user = User.get(user_id)
if user:
user.info['message'] = message
user.update_peering(False)
@ -68,7 +68,7 @@ def api_removePeering(user_id, message):
return False
def api_cancelPeering(user_id, message):
user = User.get(user_id, for_update=True)
user = User.get(user_id)
if user:
user.info['message'] = message
user.update_peering(False)

View file

@ -121,56 +121,55 @@ class Handler(http.server.SimpleHTTPRequestHandler):
else:
id = None
if id and len(id) == 32 and id.isalnum():
path = None
data = None
with db.session():
if preview:
from item.icons import get_icon_sync
try:
content = get_icon_sync(id, 'preview', 512)
data = get_icon_sync(id, 'preview', 512)
except:
content = None
if content:
data = None
if data:
self.send_response(200, 'ok')
mimetype = 'image/jpg'
self.send_header('Content-type', 'image/jpg')
else:
self.send_response(404, 'Not Found')
content = b'404 - Not Found'
mimetype = 'text/plain'
self.send_header('Content-type', 'text/plain')
data = b'404 - Not Found'
content_length = len(data)
self.send_header('Content-Length', str(content_length))
self.end_headers()
self.write_with_limit(data, content_length)
return
file = item.models.File.get(id)
if not file:
self.send_response(404, 'Not Found')
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(b'404 - Not Found')
return
path = file.fullpath()
mimetype = {
'epub': 'application/epub+zip',
'pdf': 'application/pdf',
'txt': 'text/plain',
}.get(path.split('.')[-1], None)
self.send_response(200, 'OK')
self.send_header('Content-Type', mimetype)
self.send_header('X-Node-Protocol', settings.NODE_PROTOCOL)
if mimetype == 'text/plain':
with open(path, 'rb') as f:
content = f.read()
content = self.gzip_data(content)
content_length = len(content)
else:
file = item.models.File.get(id)
if file:
path = file.fullpath()
mimetype = {
'epub': 'application/epub+zip',
'pdf': 'application/pdf',
'txt': 'text/plain',
}.get(path.split('.')[-1], None)
self.send_response(200, 'OK')
else:
self.send_response(404, 'Not Found')
content = b'404 - Not Found'
mimetype = 'text/plain'
self.send_header('Content-Type', mimetype)
self.send_header('X-Node-Protocol', settings.NODE_PROTOCOL)
if mimetype == 'text/plain' and path:
with open(path, 'rb') as f:
content = f.read()
content = self.gzip_data(content)
content_length = len(content)
elif path:
content = None
content_length = os.path.getsize(path)
elif content:
content_length = len(content)
else:
content_length = 0
self.send_header('Content-Length', str(content_length))
self.end_headers()
if content:
self.write_with_limit(content, content_length)
elif path:
self.write_file_with_limit(path, content_length)
content = None
content_length = os.path.getsize(path)
self.send_header('Content-Length', str(content_length))
self.end_headers()
if content:
self.write_with_limit(content, content_length)
else:
self.write_file_with_limit(path, content_length)
elif len(parts) == 2 and parts[1] == 'log':
self._changelog()
else:

View file

@ -340,9 +340,8 @@ oml.ui.folders = function() {
var items = lists.filter(function(list) {
return list.user == '' && list.type != 'library' && list.name != 'Inbox';
});
// Library + Inbox + lists
oml.$ui.folder[0].$content
.css({height: 16 + 16 + items.length * 16 + 'px'});
.css({height: 16 + items.length * 16 + 'px'});
oml.$ui.folderList[0].options({
items: Ox.clone(items, true)
})