Skip to content

Commit

Permalink
fix: waitForConfig, unix vd umount
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Aug 27, 2024
1 parent 70390cc commit 43e1f52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export function setConfig(config: FilenDesktopConfig): void {

export function waitForConfig(): Promise<FilenDesktopConfig> {
return new Promise<FilenDesktopConfig>(resolve => {
if (CONFIG) {
if (CONFIG && CONFIG.sdkConfig.apiKey && CONFIG.sdkConfig.apiKey.length > 32) {
resolve(CONFIG)

return
}

const wait = setInterval(() => {
if (CONFIG) {
if (CONFIG && CONFIG.sdkConfig.apiKey && CONFIG.sdkConfig.apiKey.length > 32) {
clearInterval(wait)

resolve(CONFIG)
Expand Down
7 changes: 4 additions & 3 deletions src/worker/virtualDrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,17 @@ export class VirtualDrive {

if (process.platform === "linux" || process.platform === "darwin") {
const desktopConfig = await this.worker.waitForConfig()
const umountCmd = `umount -f ${this.normalizePathForCmd(desktopConfig.virtualDriveConfig.mountPoint)}`
let listedMounts = await execCommand(`mount -t ${process.platform === "linux" ? "fuse.rclone" : "nfs"}`)
const umountCmd = `umount -f -l ${this.normalizePathForCmd(desktopConfig.virtualDriveConfig.mountPoint)}`
const listCmd = `mount -t ${process.platform === "linux" ? "fuse.rclone" : "nfs"}`
let listedMounts = await execCommand(listCmd)

if (listedMounts.length > 0 && listedMounts.includes(this.normalizePathForCmd(desktopConfig.virtualDriveConfig.mountPoint))) {
await execCommand(umountCmd).catch(() => {})
}

await new Promise<void>(resolve => setTimeout(resolve, 1000))

listedMounts = await execCommand(`mount -t ${process.platform === "linux" ? "fuse.rclone" : "nfs"}`)
listedMounts = await execCommand(listCmd)

if (listedMounts.length > 0 && listedMounts.includes(this.normalizePathForCmd(desktopConfig.virtualDriveConfig.mountPoint))) {
await execCommandSudo(umountCmd).catch(() => {})
Expand Down
4 changes: 2 additions & 2 deletions src/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export class Worker {

public async waitForConfig(): Promise<FilenDesktopConfig> {
return new Promise<FilenDesktopConfig>(resolve => {
if (this.desktopConfig) {
if (this.desktopConfig && this.desktopConfig.sdkConfig.apiKey && this.desktopConfig.sdkConfig.apiKey.length > 32) {
resolve(this.desktopConfig)

return
}

const wait = setInterval(() => {
if (this.desktopConfig) {
if (this.desktopConfig && this.desktopConfig.sdkConfig.apiKey && this.desktopConfig.sdkConfig.apiKey.length > 32) {
clearInterval(wait)

resolve(this.desktopConfig)
Expand Down

0 comments on commit 43e1f52

Please sign in to comment.