Skip to content

Commit

Permalink
feat(service): Extend listFolderContentsFromPath to include full remo…
Browse files Browse the repository at this point in the history
…te path of file, and launches f
  • Loading branch information
jezhiggins committed Jun 20, 2020
1 parent fb0b9e7 commit eba19c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/components/services/localfilestorage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ const fs = require('fs')
const fsp = require('fs').promises

class LocalFilestorage {
boot (options) {
async boot (options) {
this.rootPath_ = configuredRootPath(options)

const cloudstorage = cloudstorageService(options)
cloudstorage.registerProvider(this)

const { temp } = options.bootedServices
this.downloadDir = await temp.makeTempDir('download')
} // boot

get rootPath () { return this.rootPath_ }
Expand All @@ -27,17 +30,20 @@ class LocalFilestorage {
const rootedPath = this.resolvePath(folderPath)
if (!rootedPath) return []

const resolvedFolderPath = rootedPath.substring(this.rootPath_.length)
try {
const contents = (await fsp.readdir(rootedPath, { withFileTypes: true }))
.filter(content => content.isFile() || content.isDirectory())
.map(content => {
return {
Name: content.name,
Path: path.join(resolvedFolderPath, content.name),
launches: [{
stateMachineName: 'tymly_downloadFromLocalFileStorage_1_0',
title: 'Download',
input: {
name: content.name
localFolderPath: this.downloadDir,
remoteFilePath: path.join(resolvedFolderPath, content.name)
}
}]
}
Expand Down

0 comments on commit eba19c6

Please sign in to comment.