mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A randomly generated device id that persists in local storage
This commit is contained in:
parent
d559ab9e01
commit
352a6d9238
@ -1,9 +1,12 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __python__ import hash_literals, bound_methods
|
from __python__ import bound_methods, hash_literals
|
||||||
|
|
||||||
|
from uuid import short_uuid
|
||||||
|
|
||||||
from ajax import ajax_send
|
from ajax import ajax_send
|
||||||
|
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
# Book list settings
|
# Book list settings
|
||||||
'view_mode': 'cover_grid',
|
'view_mode': 'cover_grid',
|
||||||
@ -45,6 +48,7 @@ is_local_setting = {
|
|||||||
'base_font_size': True,
|
'base_font_size': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def storage_available(which):
|
def storage_available(which):
|
||||||
which = which or 'localStorage'
|
which = which or 'localStorage'
|
||||||
try:
|
try:
|
||||||
@ -134,6 +138,18 @@ def local_storage():
|
|||||||
local_storage.storage = SessionData('calibre-local-')
|
local_storage.storage = SessionData('calibre-local-')
|
||||||
return local_storage.storage
|
return local_storage.storage
|
||||||
|
|
||||||
|
|
||||||
|
def get_device_uuid():
|
||||||
|
if not get_device_uuid.ans:
|
||||||
|
s = local_storage()
|
||||||
|
ans = s.get('device_uuid')
|
||||||
|
if not ans:
|
||||||
|
ans = short_uuid()
|
||||||
|
s.set('device_uuid', ans)
|
||||||
|
get_device_uuid.ans = ans
|
||||||
|
return get_device_uuid.ans
|
||||||
|
|
||||||
|
|
||||||
default_interface_data = {
|
default_interface_data = {
|
||||||
'username': None,
|
'username': None,
|
||||||
'output_format': 'EPUB',
|
'output_format': 'EPUB',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user