Skip to content

Commit

Permalink
Do not open MusicDatabase when upgrade module is called
Browse files Browse the repository at this point in the history
  • Loading branch information
rstemmer committed Jul 19, 2020
1 parent e1ea154 commit ba15674
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions musicdb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,17 @@ if __name__ == "__main__":
loglevel = config.log.loglevel
log.Reconfigure(logfile, loglevel, debugfile, config)


# Get module name that shall be executed
try:
modulename = args.module
except:
argparser.print_help()
exit(1)


# get, check and open the database from path
# In case the module is "upgrade", do not open MusicDatabase - it my be outdated
databasepath = config.database.path

if not fs.IsFile(databasepath):
Expand All @@ -188,21 +198,17 @@ if __name__ == "__main__":

try:
fs.AssertFile(databasepath)
database = MusicDatabase(databasepath)
if modulename == "upgrade":
database = None
else:
database = MusicDatabase(databasepath)
except Exception as e:
print("\033[1;31mFATAL ERROR: Opening database failed!\033[0m (" + databasepath + ")")
print(e)
exit(1)



# execute module
try:
modulename = args.module
except:
argparser.print_help()
exit(1)

modclass = getattr(modules[modulename], modulename)
modobj = modclass(config, database)
exitcode = modobj.MDBM_Main(args)
Expand Down

0 comments on commit ba15674

Please sign in to comment.