Skip to content

Commit

Permalink
use base64 encoded md5 hash of working dir to build the unique worksp…
Browse files Browse the repository at this point in the history
…ace dir (#3608)

Also adds a dependency on package:crypto
  • Loading branch information
jakemac53 authored Nov 8, 2023
1 parent fae6ed1 commit 766cf18
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion build_daemon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 4.0.1-wip
## 4.0.1

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

## 4.0.0
Expand Down
9 changes: 5 additions & 4 deletions build_daemon/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:convert';
import 'dart:io';

import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as p;

const readyToConnectLog = 'READY TO CONNECT';
Expand Down Expand Up @@ -42,10 +44,9 @@ var _username = Platform.environment['USER'] ?? '';
String daemonWorkspace(String workingDirectory) {
var segments = [Directory.systemTemp.path];
if (_username.isNotEmpty) segments.add(_username);
segments.add(workingDirectory
.replaceAll('/', '_')
.replaceAll(':', '_')
.replaceAll('\\', '_'));
final workingDirHash =
base64Encode(md5.convert(workingDirectory.codeUnits).bytes);
segments.add(workingDirHash);
return p.joinAll(segments);
}

Expand Down
3 changes: 2 additions & 1 deletion build_daemon/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build_daemon
version: 4.0.1-wip
version: 4.0.1
description: A daemon for running Dart builds.
repository: https://github.com/dart-lang/build/tree/master/build_daemon

Expand All @@ -9,6 +9,7 @@ environment:
dependencies:
built_collection: ^5.0.0
built_value: ^8.1.0
crypto: ^3.0.3
http_multi_server: ^3.0.0
logging: ^1.0.0
path: ^1.8.0
Expand Down

0 comments on commit 766cf18

Please sign in to comment.