Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: utils/pub/validator/size.dart

Issue 12094093: Add a validator that tests the size of pub packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library size_validator;
6
7 import 'dart:async';
8 import 'dart:math' as math;
9
10 import '../entrypoint.dart';
11 import '../validator.dart';
12
13 /// The maximum size of the package to upload (10 MB).
14 final _MAX_SIZE = 10 * math.pow(2, 20);
Bob Nystrom 2013/02/01 01:29:44 This should either be _maxSize (since it's not con
nweiz 2013/02/01 02:08:00 Done.
15
16 /// A validator that validates that a package isn't too big.
17 class SizeValidator extends Validator {
18 final Future<int> packageSize;
19
20 SizeValidator(Entrypoint entrypoint, this.packageSize)
21 : super(entrypoint);
22
23 Future validate() {
24 return packageSize.then((size) {
25 if (size <= _MAX_SIZE) return;
26 var sizeInMb = (size / math.pow(2, 20)).toStringAsPrecision(4);
27 errors.add("Your package is $sizeInMb MB. Hosted packages may be at most "
28 "10 MB large.");
Bob Nystrom 2013/02/01 01:29:44 How about "Hosted packages must be smaller than 10
nweiz 2013/02/01 02:08:00 Done.
29 });
30 }
31 }
32
OLDNEW
« no previous file with comments | « utils/pub/validator.dart ('k') | utils/tests/pub/validator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698