fix filenotfound error in softreset, added softreset event
This commit is contained in:
parent
0405eda30e
commit
fbe1766aea
@ -23,15 +23,24 @@ import shutil
|
|||||||
from onionrutils import localcommand
|
from onionrutils import localcommand
|
||||||
from coredb import dbfiles
|
from coredb import dbfiles
|
||||||
import filepaths
|
import filepaths
|
||||||
|
import onionrevents
|
||||||
import logger
|
import logger
|
||||||
|
|
||||||
|
def _ignore_not_found_delete(path):
|
||||||
|
try:
|
||||||
|
os.remove(path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
def soft_reset():
|
def soft_reset():
|
||||||
if localcommand.local_command('/ping') == 'pong!':
|
if localcommand.local_command('/ping') == 'pong!':
|
||||||
logger.warn('Cannot soft reset while Onionr is running', terminal=True)
|
logger.warn('Cannot soft reset while Onionr is running', terminal=True)
|
||||||
return
|
return
|
||||||
path = filepaths.block_data_location
|
path = filepaths.block_data_location
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
os.remove(dbfiles.block_meta_db)
|
_ignore_not_found_delete(dbfiles.block_meta_db)
|
||||||
os.remove(filepaths.upload_list)
|
_ignore_not_found_delete(filepaths.upload_list)
|
||||||
|
onionrevents.event('softreset')
|
||||||
logger.info("Soft reset Onionr", terminal=True)
|
logger.info("Soft reset Onionr", terminal=True)
|
||||||
|
|
||||||
soft_reset.onionr_help = "Deletes Onionr blocks and their associated metadata, except for any exported block files."
|
soft_reset.onionr_help = "Deletes Onionr blocks and their associated metadata, except for any exported block files."
|
@ -99,13 +99,12 @@ class OnionrFlow:
|
|||||||
def on_flow_cmd(api, data=None):
|
def on_flow_cmd(api, data=None):
|
||||||
OnionrFlow().start()
|
OnionrFlow().start()
|
||||||
|
|
||||||
def on_init(api, data = None):
|
def on_softreset(api, data=None):
|
||||||
'''
|
try:
|
||||||
This event is called after Onionr is initialized, but before the command
|
os.remove(identifyhome.identify_home() + '/board-index.cache.json')
|
||||||
inputted is executed. Could be called when daemon is starting or when
|
logger.info('Cleared Circles board cache')
|
||||||
just the client is running.
|
except FileNotFoundError:
|
||||||
'''
|
pass
|
||||||
return
|
|
||||||
|
|
||||||
def on_processblocks(api, data=None):
|
def on_processblocks(api, data=None):
|
||||||
metadata = data['block'].bmetadata # Get the block metadata
|
metadata = data['block'].bmetadata # Get the block metadata
|
||||||
|
Loading…
Reference in New Issue
Block a user