Skip to content

Commit

Permalink
chore: fix mixed download files/folders
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Dover <[email protected]>
  • Loading branch information
Scott Dover authored and Scott Dover committed Oct 18, 2024
1 parent 315ed1c commit f863576
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions client/src/connection/rest/RestSASServerAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
} from "./util";

const SAS_SERVER_HOME_DIRECTORY = "SAS_SERVER_HOME_DIRECTORY";
const SAS_FILE_SEPARATOR = "~fs~";

class RestSASServerAdapter implements ContentAdapter {
protected baseUrl: string;
Expand Down Expand Up @@ -93,7 +94,7 @@ class RestSASServerAdapter implements ContentAdapter {
}

public connected(): boolean {
return !!this.sessionId;
return true;
}

public async setup(): Promise<void> {
Expand Down Expand Up @@ -271,9 +272,9 @@ class RestSASServerAdapter implements ContentAdapter {
public async getParentOfItem(
item: ContentItem,
): Promise<ContentItem | undefined> {
const parentPathPieces = this.trimComputePrefix(item.uri).split("~fs~");
parentPathPieces.pop();
const fileOrDirectoryPath = parentPathPieces.join("~fs~");
const fileOrDirectoryPath = this.getParentPathOfUri(
this.trimComputePrefix(item.uri),
);
const response = await this.fileSystemApi.getFileorDirectoryProperties({
sessionId: this.sessionId,
fileOrDirectoryPath,
Expand Down Expand Up @@ -335,7 +336,7 @@ class RestSASServerAdapter implements ContentAdapter {
ifMatch: etag,
fileProperties: {
name: item.name,
path: newFilePath.split("~fs~").join("/"),
path: newFilePath.split(SAS_FILE_SEPARATOR).join("/"),
},
};

Expand All @@ -353,7 +354,7 @@ class RestSASServerAdapter implements ContentAdapter {
): Promise<ContentItem | undefined> {
const filePath = this.trimComputePrefix(item.uri);

const parsedFilePath = filePath.split("~fs~");
const parsedFilePath = filePath.split(SAS_FILE_SEPARATOR);
parsedFilePath.pop();
const path = parsedFilePath.join("/");

Expand Down Expand Up @@ -394,6 +395,12 @@ class RestSASServerAdapter implements ContentAdapter {
this.updateFileMetadata(filePath, response);
}

private getParentPathOfUri(uri: string) {
const uriPieces = uri.split(SAS_FILE_SEPARATOR);
uriPieces.pop();
return uriPieces.join(SAS_FILE_SEPARATOR);
}

private filePropertiesToContentItem(
fileProperties: FileProperties & { type?: string },
flags?: ContentItem["flags"],
Expand Down Expand Up @@ -426,6 +433,7 @@ class RestSASServerAdapter implements ContentAdapter {
},
flags,
type: fileProperties.type || "",
parentFolderUri: this.getParentPathOfUri(id),
};

const typeName = getTypeName(item);
Expand Down

0 comments on commit f863576

Please sign in to comment.