mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-25 17:09:09 +00:00
ensure sheets directory
This commit is contained in:
@@ -9,6 +9,7 @@ import { DatabaseModel, LogOrigin } from 'ontime-types';
|
|||||||
import { ExcelImportOptions, isExcelImportMap } from 'ontime-utils';
|
import { ExcelImportOptions, isExcelImportMap } from 'ontime-utils';
|
||||||
import { parseExcel } from './parser.js';
|
import { parseExcel } from './parser.js';
|
||||||
import { parseProject, parseRundown, parseUserFields } from './parserFunctions.js';
|
import { parseProject, parseRundown, parseUserFields } from './parserFunctions.js';
|
||||||
|
import { ensureDirectory } from './fileManagement.js';
|
||||||
|
|
||||||
type ResponseOK = {
|
type ResponseOK = {
|
||||||
data: Partial<DatabaseModel>;
|
data: Partial<DatabaseModel>;
|
||||||
@@ -17,8 +18,9 @@ type ResponseOK = {
|
|||||||
class sheet {
|
class sheet {
|
||||||
private static client: null | OAuth2Client = null;
|
private static client: null | OAuth2Client = null;
|
||||||
private readonly scope = 'https://www.googleapis.com/auth/spreadsheets';
|
private readonly scope = 'https://www.googleapis.com/auth/spreadsheets';
|
||||||
private readonly client_secret = getAppDataPath() + '/client_secret.json';
|
private readonly sheetsFolder = getAppDataPath() + '/sheets';
|
||||||
private readonly token = getAppDataPath() + '/token.json';
|
private readonly client_secret = this.sheetsFolder + '/client_secret.json';
|
||||||
|
private readonly token = this.sheetsFolder + '/token.json';
|
||||||
private static authUrl: null | string = null;
|
private static authUrl: null | string = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +83,8 @@ class sheet {
|
|||||||
* @param {Object} secrets
|
* @param {Object} secrets
|
||||||
*/
|
*/
|
||||||
public async saveClientSecrets(secrets: Object) {
|
public async saveClientSecrets(secrets: Object) {
|
||||||
|
ensureDirectory(this.sheetsFolder);
|
||||||
|
logger.info(LogOrigin.Server, 'Sheets: got new client_secret');
|
||||||
//TODO: test that this is actualy a client file?
|
//TODO: test that this is actualy a client file?
|
||||||
//invalidate previus auths
|
//invalidate previus auths
|
||||||
sheet.client = null;
|
sheet.client = null;
|
||||||
@@ -142,7 +146,7 @@ class sheet {
|
|||||||
if (sheet.authUrl) {
|
if (sheet.authUrl) {
|
||||||
return sheet.authUrl;
|
return sheet.authUrl;
|
||||||
}
|
}
|
||||||
const creadFile = await readFile(getAppDataPath() + '/credentials.json', 'utf-8').catch((err) =>
|
const creadFile = await readFile(this.client_secret, 'utf-8').catch((err) =>
|
||||||
logger.error(LogOrigin.Server, `${err}`),
|
logger.error(LogOrigin.Server, `${err}`),
|
||||||
);
|
);
|
||||||
if (!creadFile) {
|
if (!creadFile) {
|
||||||
|
|||||||
Reference in New Issue
Block a user