Skip to content

Commit

Permalink
Fixed handling of default value
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Oct 11, 2023
1 parent b9a2dd3 commit 8ab3ac9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/commoniface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def genrevalock(appname, value):
"user": {},
"expiration": {
"seconds": int(time.time())
+ config.getint("general", "wopilockexpiration")
+ config.getint('general', 'wopilockexpiration')
},
}
).encode()
Expand Down
2 changes: 1 addition & 1 deletion src/core/wopiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def generateAccessToken(userid, fileid, viewmode, user, folderurl, endpoint, app
except IOError as e:
log.info(f'msg="Requested file not found or not a file" fileid="{fileid}" error="{e}"')
raise
exptime = int(time.time()) + srv.tokenvalidity
exptime = int(time.time()) + srv.config.getint('general', 'tokenvalidity')
fext = os.path.splitext(statinfo['filepath'])[1].lower()
if srv.config.get('general', 'disablemswriteodf', fallback='False').upper() == 'TRUE' and \
fext[1:3] in ('od', 'ot') and appname not in ('Collabora', '') and viewmode == ViewMode.READ_WRITE:
Expand Down
12 changes: 6 additions & 6 deletions src/wopiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Wopi:
app = flask.Flask("wopiserver")
metrics = PrometheusMetrics(app, group_by='endpoint')
port = 0
lastConfigReadTime = time.time()
lastConfigReadTime = 0
loglevels = {"Critical": logging.CRITICAL, # 50
"Error": logging.ERROR, # 40
"Warning": logging.WARNING, # 30
Expand Down Expand Up @@ -115,7 +115,6 @@ def init(cls):
storage_layer_import(cls.config.get('general', 'storagetype'))
# prepare the Flask web app
cls.port = int(cls.config.get('general', 'port'))
cls.log.setLevel(cls.loglevels[cls.config.get('general', 'loglevel')])
try:
cls.nonofficetypes = cls.config.get('general', 'nonofficetypes').split()
except (TypeError, configparser.NoOptionError):
Expand All @@ -125,7 +124,6 @@ def init(cls):
cls.wopisecret = s.read().strip('\n')
with open(cls.config.get('security', 'iopsecretfile')) as s:
cls.iopsecret = s.read().strip('\n')
cls.tokenvalidity = cls.config.getint('general', 'tokenvalidity')
core.wopi.enablerename = cls.config.get('general', 'enablerename', fallback='False').upper() in ('TRUE', 'YES')
storage.init(cls.config, cls.log) # initialize the storage layer
cls.useHttps = cls.config.get('security', 'usehttps').lower() == 'yes'
Expand All @@ -147,7 +145,8 @@ def init(cls):
os.makedirs(cls.recoverypath)
except FileExistsError:
pass
_ = cls.config.getint('general', 'wopilockexpiration', fallback=1800) # make sure this is defined as an int
# read the remaining refreshable parameters
cls.refreshconfig()
# WOPI proxy configuration (optional)
cls.wopiproxy = cls.config.get('general', 'wopiproxy', fallback='')
cls.wopiproxykey = None
Expand Down Expand Up @@ -178,8 +177,9 @@ def refreshconfig(cls):
if time.time() > cls.lastConfigReadTime + 300:
cls.lastConfigReadTime = time.time()
cls.config.read('/etc/wopi/wopiserver.conf')
# refresh some general parameters
cls.tokenvalidity = cls.config.getint('general', 'tokenvalidity', fallback=86400)
# set some defaults for missing values
cls.config.set('general', 'tokenvalidity', cls.config.getint('general', 'tokenvalidity', fallback=86400))
cls.config.set('general', 'wopilockexpiration', cls.config.getint('general', 'wopilockexpiration', fallback=1800))
cls.log.setLevel(cls.loglevels[cls.config.get('general', 'loglevel')])

@classmethod
Expand Down

0 comments on commit 8ab3ac9

Please sign in to comment.