Skip to content

Commit

Permalink
Webdav network drive not work (fixes #218)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Nov 24, 2015
1 parent ff6c7a2 commit 0d43965
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
22 changes: 18 additions & 4 deletions src/vs/base/node/extfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function readdir(path: string, callback: (error: Error, files: string[])
// Mac: uses NFD unicode form on disk, but we want NFC
// See also https://github.com/nodejs/node/issues/2165
if (platform.isMacintosh) {
return fs.readdir(path, (error, children) => {
return readdirNormalize(path, (error, children) => {
if (error) {
return callback(error, null);
}
Expand All @@ -36,9 +36,23 @@ export function readdir(path: string, callback: (error: Error, files: string[])
});
}

return fs.readdir(path, callback);
return readdirNormalize(path, callback);
};

function readdirNormalize(path: string, callback: (error: Error, files: string[]) => void): void {
fs.readdir(path, (error, children) => {
if (error) {
return callback(error, null);
}

// In some environments we get "." and ".." as entries from the call to readdir().
// For example Sharepoint via WebDav on Windows includes them. We never want those
// entries in the result set though because they are not valid children of the folder
// for our concerns.
return callback(null, children.filter((c) => c !== '.' && c !== '..'));
})
}

export function mkdirp(path: string, mode: number, callback: (error: Error) => void): void {
fs.exists(path, (exists) => {
if (exists) {
Expand Down Expand Up @@ -91,7 +105,7 @@ export function copy(source: string, target: string, callback: (error: Error) =>
}

mkdirp(target, stat.mode & 511, (err) => {
fs.readdir(source, (err, files) => {
readdir(source, (err, files) => {
loop(files, (file: string, clb: (error: Error) => void) => {
copy(paths.join(source, file), paths.join(target, file), clb, copiedSources);
}, callback);
Expand Down Expand Up @@ -204,7 +218,7 @@ function rmRecursive(path: string, callback: (error: Error) => void): void {
fs.unlink(path, callback);
}
} else {
fs.readdir(path, (err, children) => {
readdir(path, (err, children) => {
if (err || !children) {
callback(err);
} else if (children.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import async = require('vs/base/common/async');
import Errors = require('vs/base/common/errors');
import URI from 'vs/base/common/uri';
import winjs = require('vs/base/common/winjs.base');
import extfs = require('vs/base/node/extfs');
import lifecycle = require('vs/base/common/lifecycle');
import tmsnippets = require('vs/editor/node/textMate/TMSnippets');
import {IFileService} from 'vs/platform/files/common/files';
Expand Down Expand Up @@ -100,7 +101,7 @@ export class SnippetsTracker implements workbenchExt.IWorkbenchContribution {

function readDir(path: string): winjs.TPromise<string[]> {
return new winjs.TPromise<string[]>((c, e, p) => {
fs.readdir(path,(err, files) => {
extfs.readdir(path,(err, files) => {
if (err) {
return e(err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import uri from 'vs/base/common/uri';
import strings = require('vs/base/common/strings');
import platform = require('vs/base/common/platform');
import paths = require('vs/base/common/paths');
import extfs = require('vs/base/node/extfs');
import {IConfigFile} from 'vs/platform/configuration/common/model';
import objects = require('vs/base/common/objects');
import {IStat, IContent, ConfigurationService as CommonConfigurationService} from 'vs/platform/configuration/common/configurationService';
Expand Down Expand Up @@ -62,9 +63,9 @@ export class ConfigurationService extends CommonConfigurationService {

protected resolveStat(resource: uri): TPromise<IStat> {
return new TPromise<IStat>((c, e) => {
fs.readdir(resource.fsPath, (error, childs) => {
extfs.readdir(resource.fsPath, (error, childs) => {
if (error) {
if (error.code === 'ENOTDIR') {
if ((<any>error).code === 'ENOTDIR') {
c({
resource: resource,
isDirectory: false
Expand Down Expand Up @@ -158,7 +159,7 @@ export class MigrationConfigurationService extends ConfigurationService {
return c(null); // we never migrate more than once
}

return fs.readdir(oldSettingsFolder, (error, children) => {
return extfs.readdir(oldSettingsFolder, (error, children) => {
if (error) {
return c(null); // old .settings folder does not exist or is a file
}
Expand Down Expand Up @@ -187,7 +188,7 @@ export class MigrationConfigurationService extends ConfigurationService {
}, () => {
this.messageService.show(severity.Info, nls.localize('settingsMigrated', "VSCode is now using a top level '.vscode' folder to store settings. We moved your existing settings files from the '.settings' folder."));

return fs.readdir(oldSettingsFolder, (error, children) => {
return extfs.readdir(oldSettingsFolder, (error, children) => {
if (error || children.length > 0) {
return c(null); // done
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/services/files/node/fileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ export class StatResolver {
fileStat = fsstat;

if (fileStat.isDirectory()) {
fs.readdir(fileResource.fsPath, (error, result) => {
extfs.readdir(fileResource.fsPath, (error, result) => {
this(null, result ? result.length : 0);
});
} else {
Expand Down

0 comments on commit 0d43965

Please sign in to comment.