Skip to content

Commit

Permalink
fix: only start workers in a node env
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed May 28, 2024
1 parent 8e606f3 commit a27d4db
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 53 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@filen/desktop",
"version": "0.1.5",
"version": "0.1.6",
"description": "Filen Desktop Client",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
Expand Down
103 changes: 53 additions & 50 deletions src/fuse/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import os from "os"
import pathModule from "path"
import fs from "fs-extra"
import { waitForSDKConfig } from "../config"
import { IS_NODE } from "../constants"

const FUSE = Fuse.default

Expand Down Expand Up @@ -154,59 +155,61 @@ export class FUSEWorker {
}
}

// TODO: Remove

const baseTmpPath = pathModule.join(os.tmpdir(), "filen-desktop")
const fullDownloadsTmpPath = pathModule.join(baseTmpPath, "fullDownloads")
const uploadsTmpPath = pathModule.join(baseTmpPath, "uploads")
const encryptedChunksTmpPath = pathModule.join(baseTmpPath, "encryptedChunks")
const decryptedChunksTmpPath = pathModule.join(baseTmpPath, "decryptedChunks")
const xattrPath = pathModule.join(baseTmpPath, "xattr")
const writeTmpPath = pathModule.join(baseTmpPath, "write")

fs.ensureDirSync(baseTmpPath)
fs.ensureDirSync(fullDownloadsTmpPath)
fs.ensureDirSync(uploadsTmpPath)
fs.ensureDirSync(encryptedChunksTmpPath)
fs.ensureDirSync(decryptedChunksTmpPath)
fs.ensureDirSync(xattrPath)
fs.ensureDirSync(writeTmpPath)

process.stdout.write(
JSON.stringify({
type: "ready"
})
)

waitForSDKConfig()
.then(sdkConfig => {
const fuseWorker = new FUSEWorker({
mountPoint: "M:",
baseTmpPath,
fullDownloadsTmpPath,
uploadsTmpPath,
encryptedChunksTmpPath,
decryptedChunksTmpPath,
xattrPath,
writeTmpPath,
sdkConfig
if (IS_NODE) {
// TODO: Remove

const baseTmpPath = pathModule.join(os.tmpdir(), "filen-desktop")
const fullDownloadsTmpPath = pathModule.join(baseTmpPath, "fullDownloads")
const uploadsTmpPath = pathModule.join(baseTmpPath, "uploads")
const encryptedChunksTmpPath = pathModule.join(baseTmpPath, "encryptedChunks")
const decryptedChunksTmpPath = pathModule.join(baseTmpPath, "decryptedChunks")
const xattrPath = pathModule.join(baseTmpPath, "xattr")
const writeTmpPath = pathModule.join(baseTmpPath, "write")

fs.ensureDirSync(baseTmpPath)
fs.ensureDirSync(fullDownloadsTmpPath)
fs.ensureDirSync(uploadsTmpPath)
fs.ensureDirSync(encryptedChunksTmpPath)
fs.ensureDirSync(decryptedChunksTmpPath)
fs.ensureDirSync(xattrPath)
fs.ensureDirSync(writeTmpPath)

process.stdout.write(
JSON.stringify({
type: "ready"
})

fuseWorker
.initialize()
.then(() => {
//
)

waitForSDKConfig()
.then(sdkConfig => {
const fuseWorker = new FUSEWorker({
mountPoint: "M:",
baseTmpPath,
fullDownloadsTmpPath,
uploadsTmpPath,
encryptedChunksTmpPath,
decryptedChunksTmpPath,
xattrPath,
writeTmpPath,
sdkConfig
})
.catch(err => {
console.error(err)

process.exit(1)
})
})
.catch(err => {
console.error(err)
fuseWorker
.initialize()
.then(() => {
//
})
.catch(err => {
console.error(err)

process.exit(1)
})
})
.catch(err => {
console.error(err)

process.exit(1)
})
process.exit(1)
})
}

export default FUSEWorker
3 changes: 2 additions & 1 deletion src/sync/worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { SyncPair } from "./types"
import Sync from "./lib/sync"
import { type FilenSDKConfig } from "@filen/sdk"
import { IS_NODE } from "../constants"

/**
* SyncWorker
Expand Down Expand Up @@ -60,7 +61,7 @@ export class SyncWorker {
}

// Only start the worker if it is actually invoked.
if (process.argv.slice(2).includes("--worker")) {
if (process.argv.slice(2).includes("--worker") && IS_NODE) {
// TODO: Proper init
const syncWorker = new SyncWorker({
dbPath: "",
Expand Down
3 changes: 2 additions & 1 deletion src/webdav/worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SDK, { type FilenSDKConfig } from "@filen/sdk"
import * as WebDAV from "@filen/webdav-server"
import FileSystem from "./filesystem"
import { IS_NODE } from "../constants"

export type WebDAVUser = {
name: string
Expand Down Expand Up @@ -101,7 +102,7 @@ export class WebDAVWorker {
}

// Only start the worker if it is actually invoked.
if (process.argv.slice(2).includes("--worker")) {
if (process.argv.slice(2).includes("--worker") && IS_NODE) {
const webdavWorker = new WebDAVWorker({
users: [
{
Expand Down

0 comments on commit a27d4db

Please sign in to comment.