Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,10 @@ export class AtelierAPI {
name: string,
scope: vscode.Uri | string,
mtime?: number,
storageOnly: boolean = false
storageOnly = false,
forceBinary = false
): Promise<Atelier.Response<Atelier.Document>> {
let params, headers;
const params: Record<string, string> = {};
name = this.transformNameIfCsp(name);
if (
this.config.apiVersion >= 4 &&
Expand All @@ -663,17 +664,19 @@ export class AtelierAPI {
)
.get("multilineMethodArgs")
) {
params = { format: "udl-multiline" };
} else {
params = {};
}
if (storageOnly) {
params["storageOnly"] = "1";
}
if (mtime && mtime > 0) {
headers = { "IF-NONE-MATCH": new Date(mtime).toISOString().replace(/T|Z/g, " ").trim() };
params.format = "udl-multiline";
}
return this.request(1, "GET", `${this.ns}/doc/${name}`, null, params, headers);
if (storageOnly) params.storageOnly = "1";
if (forceBinary) params.binary = "1";
return this.request(
1,
"GET",
`${this.ns}/doc/${name}`,
null,
params,
// headers
mtime && mtime > 0 ? { "IF-NONE-MATCH": new Date(mtime).toISOString().replace(/T|Z/g, " ").trim() } : undefined
);
}

// api v1+
Expand Down
14 changes: 2 additions & 12 deletions src/providers/FileSystemProvider/FileSystemProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as path from "path";
import * as vscode from "vscode";
import { isText } from "istextorbinary";
import { AtelierAPI } from "../../api";
import { fireOtherStudioAction, OtherStudioAction } from "../../commands/studio";
import { isfsConfig, projectContentsFromUri, studioOpenDialogFromURI } from "../../utils/FileProviderUtil";
Expand Down Expand Up @@ -541,7 +540,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
.then(
async (entry: File) => {
const contentBuffer = Buffer.from(content);
const putContent = isText(uri.path.split("/").pop(), contentBuffer)
const putContent = !csp // Web app files must always be written as raw bytes
? {
content: new TextDecoder().decode(content).split(/\r?\n/),
enc: false,
Expand Down Expand Up @@ -579,15 +578,6 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
update = true;
}
}
if (
csp &&
!putContent.enc &&
putContent.content.length > 1 &&
putContent.content[putContent.content.length - 1] == ""
) {
// Avoid appending a blank line on every save, which would cause a web app file to grow each time
putContent.content.pop();
}
// By the time we get here VS Code's built-in conflict resolution mechanism will already have interacted with the user.
// Therefore, it's safe to ignore any conflicts.
return api
Expand Down Expand Up @@ -1075,7 +1065,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
const fileName = isfsDocumentName(uri, csp);
const api = new AtelierAPI(uri);
return api
.getDoc(fileName, uri, cachedFile?.mtime)
.getDoc(fileName, uri, cachedFile?.mtime, undefined, csp) // Web app files must always be read as raw bytes
.then((data) => data.result)
.then(
({ ts, content }) =>
Expand Down