Skip to content

Commit 42f358a

Browse files
authored
Merge pull request #318 from leoafarias/feature/remove_symlink_check
Feature/remove symlink check
2 parents f1e36f4 + 3559b2a commit 42f358a

File tree

7 files changed

+21
-54
lines changed

7 files changed

+21
-54
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.0
2+
3+
- Removed Windows permission check
4+
15
## 2.0.7
26

37
- Updated Flutter releases URL

lib/src/runner.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import 'commands/releases_command.dart';
1818
import 'commands/remove_command.dart';
1919
import 'commands/spawn_command.dart';
2020
import 'commands/use_command.dart';
21-
import 'utils/guards.dart';
2221
import 'utils/helpers.dart';
2322
import 'utils/logger.dart';
2423
import 'version.dart';
@@ -67,14 +66,11 @@ class FvmCommandRunner extends CommandRunner<int> {
6766
ConsoleController.isCli = true;
6867
final _argResults = parse(args);
6968

70-
// Check that can symlink
71-
await Guards.canSymlink();
72-
73-
final exitCode = await runCommand(_argResults) ?? ExitCode.success.code;
74-
7569
// Command might be null
7670
final cmd = _argResults.command?.name;
7771

72+
final exitCode = await runCommand(_argResults) ?? ExitCode.success.code;
73+
7874
// Check if its running the latest version of FVM
7975
if (cmd == 'use' || cmd == 'install' || cmd == 'remove') {
8076
// Check if there is an update fofr FVM

lib/src/services/context.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ class FvmContext {
7575
/// Where Default Flutter SDK is stored
7676
Link get globalCacheLink => Link(join(_fvmDir.path, 'default'));
7777

78-
/// Used to test that it can link
79-
Link get testLinkSource => Link(join(_fvmDir.path, '.test_link'));
80-
81-
/// Used to test it links to target
82-
Directory get testLinkTarget => Directory(
83-
join(_fvmDir.path, '.test_link_target'),
84-
);
85-
8678
/// Directory for Global Flutter SDK bin
8779
String get globalCacheBinPath => join(
8880
globalCacheLink.path,

lib/src/utils/guards.dart

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import 'dart:io';
2-
31
import 'package:io/io.dart';
42

53
import '../../exceptions.dart';
6-
import '../services/context.dart';
7-
import 'helpers.dart';
8-
import 'logger.dart';
94

105
/// Guards against certain action by validatin and throwing errors
116
class Guards {
@@ -15,35 +10,4 @@ class Guards {
1510
throw FvmInternalError('Cannot execute $execPath');
1611
}
1712
}
18-
19-
/// Checks if user can create symlink
20-
static Future<void> canSymlink() async {
21-
if (!Platform.isWindows) return;
22-
try {
23-
if (!await ctx.testLinkTarget.exists()) {
24-
await ctx.testLinkTarget.create(recursive: true);
25-
}
26-
await createLink(ctx.testLinkSource, ctx.testLinkTarget);
27-
} on Exception catch (err) {
28-
logger.trace(err.toString());
29-
var message = '';
30-
if (Platform.isWindows) {
31-
message = 'On Windows FVM requires to run as an administrator '
32-
'or turn on developer mode: https://bit.ly/3vxRr2M';
33-
}
34-
35-
throw FvmUsageException(
36-
"Seems you don't have the required permissions on ${ctx.fvmHome.path}"
37-
' $message',
38-
);
39-
} finally {
40-
// Clean up
41-
if (await ctx.testLinkSource.exists()) {
42-
await ctx.testLinkSource.delete();
43-
}
44-
if (await ctx.testLinkTarget.exists()) {
45-
await ctx.testLinkTarget.delete();
46-
}
47-
}
48-
}
4913
}

lib/src/utils/helpers.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:path/path.dart';
66
import 'package:process_run/shell.dart';
77

88
import '../../constants.dart';
9+
import '../../exceptions.dart';
910
import '../services/context.dart';
1011
import '../version.dart';
1112
import 'logger.dart';
@@ -71,8 +72,18 @@ Future<void> createLink(Link source, FileSystemEntity target) async {
7172
recursive: true,
7273
);
7374
} on FileSystemException catch (e) {
74-
logger.trace(e.message);
75-
rethrow;
75+
logger.trace(e.toString());
76+
77+
var message = '';
78+
if (Platform.isWindows) {
79+
message = 'On Windows FVM requires to run as an administrator '
80+
'or turn on developer mode: https://bit.ly/3vxRr2M';
81+
}
82+
83+
throw FvmUsageException(
84+
"Seems you don't have the required permissions on ${ctx.fvmHome.path}"
85+
' $message',
86+
);
7687
}
7788
}
7889

lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: fvm
22
description: A simple cli to manage Flutter SDK versions per project. Support
33
channels, releases, and local cache for fast switching between versions.
4-
version: 2.0.7
4+
version: 2.1.0
55
homepage: https://github.com/leoafarias/fvm
66

77
environment:

0 commit comments

Comments
 (0)