From 5b889757f9d104b032c4c062343662da12792bfd Mon Sep 17 00:00:00 2001 From: Aleksandar Acic Date: Thu, 12 Oct 2023 19:34:40 -0500 Subject: [PATCH] Check if tp directory is writable. --- server/dataset/termdb.test.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/server/dataset/termdb.test.ts b/server/dataset/termdb.test.ts index 332d601879..c41176f869 100644 --- a/server/dataset/termdb.test.ts +++ b/server/dataset/termdb.test.ts @@ -1,7 +1,7 @@ import { Mds3 } from '../shared/types' import * as serverconfig from '@sjcrh/proteinpaint-server/src/serverconfig.js' import * as path from 'path' -import { existsSync, unlinkSync, symlinkSync } from 'fs' +import { existsSync, unlinkSync, symlinkSync, access, constants } from 'fs' /* the "test mule" for the type of termdb dataset using server-side sqlite3 db @@ -244,11 +244,17 @@ function copyDataFilesFromRepo2Tp() { const datadir = path.join(serverconfig.tpmasterdir, 'files/hg38/TermdbTest') if (!targetDir.endsWith(datadir)) { - try { - if (existsSync(datadir)) unlinkSync(datadir) - symlinkSync(targetDir, datadir) - } catch (error) { - console.warn('Error while coping data files from Repo to Tp: ' + error) - } + access(datadir, constants.R_OK | constants.W_OK, err => { + if (!err) { + try { + if (existsSync(datadir)) unlinkSync(datadir) + symlinkSync(targetDir, datadir) + } catch (error) { + console.warn('Error while coping data files from Repo to Tp: ' + error) + } + } else { + console.warn(`user doesn't have sufficient permissions for `) + } + }) } }