fileService.ts ×3

Frontier kind: Code frontier

unlabeled · c_87acf067f08b

160 tests · 11774 LOC · 44 files · introduces 0 tests · 27 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
3 ranges27 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1890 ranges11774 lines · 44 files · Browse complete extent
All tests (intent)
160 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 27 introduced LOC across 3 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/files/common/fileService.ts 27 introduced LOC · 3 ranges

Open complete file

489 return Object.create(null); // file might not exist
490 }
492 > // File cannot be directory
493 > if ((stat.type & FileType.Directory) !== 0) {
494 throw new FileOperationError(localize('fileIsDirectoryWriteError', "Unable to write file '{0}' that is actually a directory", this.resourceForError(resource)), FileOperationResult.FILE_IS_DIRECTORY, options);
495 }
497 > // File cannot be readonly
498 > this.throwIfFileIsReadonly(resource, stat);
499 >
500 > // Dirty write prevention: if the file on disk has been changed and does not match our expected
501 > // mtime and etag, we bail out to prevent dirty writing.
502 > //
503 > // First, we check for a mtime that is in the future before we do more checks. The assumption is
504 > // that only the mtime is an indicator for a file that has changed on disk.
505 > //
506 > // Second, if the mtime has advanced, we compare the size of the file on disk with our previous
507 > // one using the etag() function. Relying only on the mtime check has prooven to produce false
508 > // positives due to file system weirdness (especially around remote file systems). As such, the
509 > // check for size is a weaker check because it can return a false negative if the file has changed
510 > // but to the same length. This is a compromise we take to avoid having to produce checksums of
511 > // the file content for comparison which would be much slower to compute.
512 > //
513 > // Third, if the etag() turns out to be different, we do one attempt to compare the buffer we
514 > // are about to write with the contents on disk to figure out if the contents are identical.
515 > // In that case we allow the writing as it would result in the same contents in the file.
516 > let buffer: VSBuffer | VSBufferReadable | VSBufferReadableStream | VSBufferReadableBufferedStream | undefined;
517 > if (
518 typeof options?.mtime === 'number' && typeof options.etag === 'string' && options.etag !== ETAG_DISABLED &&
519 typeof stat.mtime === 'number' && typeof stat.size === 'number' &&
534 throw new FileOperationError(localize('fileModifiedError', "File Modified Since"), FileOperationResult.FILE_MODIFIED_SINCE, options);
535 }
537 > return { stat, buffer };
538 }
539