Skip to content

Commit 766cf18

Browse files
authored
use base64 encoded md5 hash of working dir to build the unique workspace dir (#3608)
Also adds a dependency on package:crypto
1 parent fae6ed1 commit 766cf18

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

build_daemon/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## 4.0.1-wip
1+
## 4.0.1
22

3+
- Use a hash of the working dir to create the unique workspace dir. This
4+
resolves an issue when file names become too long.
35
- Bump the min sdk to 3.0.0.
46

57
## 4.0.0

build_daemon/lib/constants.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:convert';
56
import 'dart:io';
67

8+
import 'package:crypto/crypto.dart';
79
import 'package:path/path.dart' as p;
810

911
const readyToConnectLog = 'READY TO CONNECT';
@@ -42,10 +44,9 @@ var _username = Platform.environment['USER'] ?? '';
4244
String daemonWorkspace(String workingDirectory) {
4345
var segments = [Directory.systemTemp.path];
4446
if (_username.isNotEmpty) segments.add(_username);
45-
segments.add(workingDirectory
46-
.replaceAll('/', '_')
47-
.replaceAll(':', '_')
48-
.replaceAll('\\', '_'));
47+
final workingDirHash =
48+
base64Encode(md5.convert(workingDirectory.codeUnits).bytes);
49+
segments.add(workingDirHash);
4950
return p.joinAll(segments);
5051
}
5152

build_daemon/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_daemon
2-
version: 4.0.1-wip
2+
version: 4.0.1
33
description: A daemon for running Dart builds.
44
repository: https://github.com/dart-lang/build/tree/master/build_daemon
55

@@ -9,6 +9,7 @@ environment:
99
dependencies:
1010
built_collection: ^5.0.0
1111
built_value: ^8.1.0
12+
crypto: ^3.0.3
1213
http_multi_server: ^3.0.0
1314
logging: ^1.0.0
1415
path: ^1.8.0

0 commit comments

Comments
 (0)