Skip to content

Commit

Permalink
Add a workaround when getting a file with JSON contents
Browse files Browse the repository at this point in the history
I still don't like this workaround because you're not getting the raw file contents.
Needs an upstream fix: perry-mitchell/webdav-client#267
  • Loading branch information
mofojed committed Aug 9, 2021
1 parent 2334c53 commit c5a6ef1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/code-studio/src/dashboard/DashboardContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ DashboardContainer.contextType = ReactReduxContext;

const mapStateToProps = state => ({
activeTool: getActiveTool(state),
session: getSession(state),
session: getSession(state).session,
});

export default connect(mapStateToProps, {
Expand Down
10 changes: 9 additions & 1 deletion packages/file-explorer/src/WebdavFileStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ export class WebdavFileStorage implements FileStorage {
}

async loadFile(name: string): Promise<File> {
const content = await this.client.getFileContents(name, {
let content = await this.client.getFileContents(name, {
format: 'text',
});

// There appears to be a bug where data is returned as an object instead of a string
// Work around for now
// https://github.com/perry-mitchell/webdav-client/issues/267
if (typeof content === 'object') {
content = JSON.stringify(content, null, 2);
}

return {
filename: name,
basename: FileUtils.getBaseName(name),
Expand Down

0 comments on commit c5a6ef1

Please sign in to comment.