Skip to content

Commit e3fae47

Browse files
author
Benjamin Pasero
committed
hot exit - use # as separator for better forwards compatibilty
1 parent aad3a22 commit e3fae47

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/vs/workbench/services/backup/node/backupFileService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ export class BackupFilesModel implements IBackupFilesModel {
8282
return false; // unknown resource
8383
}
8484

85-
if (typeof versionId === 'number' && typeof entry.versionId === 'number' && entry.versionId !== versionId) {
85+
if (typeof versionId === 'number' && versionId !== entry.versionId) {
8686
return false; // different versionId
8787
}
8888

89-
if (meta && entry.meta && !equals(meta, entry.meta)) {
89+
if (meta && !equals(meta, entry.meta)) {
9090
return false; // different metadata
9191
}
9292

@@ -166,7 +166,7 @@ export class BackupFileService implements IBackupFileService {
166166
class BackupFileServiceImpl implements IBackupFileService {
167167

168168
private static readonly PREAMBLE_END_MARKER = '\n';
169-
private static readonly PREAMBLE_META_START_MARKER = ' ';
169+
private static readonly PREAMBLE_META_START_MARKER = '#'; // using a character that is know to be escaped in a URI as separator
170170
private static readonly PREAMBLE_MAX_LENGTH = 10000;
171171

172172
_serviceBrand: any;
@@ -336,7 +336,7 @@ class BackupFileServiceImpl implements IBackupFileService {
336336
const metaStartIndex = metaRaw.indexOf(BackupFileServiceImpl.PREAMBLE_META_START_MARKER);
337337
if (metaStartIndex !== -1) {
338338
try {
339-
meta = JSON.parse(metaRaw.substr(metaStartIndex));
339+
meta = JSON.parse(metaRaw.substr(metaStartIndex + 1));
340340
} catch (error) {
341341
// ignore JSON parse errors
342342
}

src/vs/workbench/services/backup/test/node/backupFileService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ suite('BackupFileService', () => {
162162
await service.backupResource(fooFile, createTextBufferFactory('test').create(DefaultEndOfLine.LF).createSnapshot(false), undefined, { etag: '678', orphaned: true });
163163
assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'file')).length, 1);
164164
assert.equal(fs.existsSync(fooBackupPath), true);
165-
assert.equal(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()} {"etag":"678","orphaned":true}\ntest`);
165+
assert.equal(fs.readFileSync(fooBackupPath).toString(), `${fooFile.toString()}#{"etag":"678","orphaned":true}\ntest`);
166166
});
167167

168168
test('untitled file', async () => {

0 commit comments

Comments
 (0)