Skip to content

Commit 6054ca6

Browse files
committed
Fixed very dumb smolId caching bug.
1 parent 7bec7ec commit 6054ca6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/models/mod_variant.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,16 @@ final smolIdAllowedChars = RegExp(r'[^0-9a-zA-Z\\.\-_]');
154154
final _smolIdCache = <String, String>{};
155155

156156
String createSmolId(String id, Version? version) {
157-
if (_smolIdCache.containsKey(id)) {
158-
return _smolIdCache[id]!;
157+
final versionString = version.toString();
158+
final cacheKey = '$id-$versionString';
159+
160+
if (_smolIdCache.containsKey(cacheKey)) {
161+
return _smolIdCache[cacheKey]!;
159162
}
160163

161164
final result =
162-
'${id.replaceAll(smolIdAllowedChars, '').take(6)}-${version.toString().replaceAll(smolIdAllowedChars, '').take(9)}-${(id.hashCode + version.hashCode).abs()}';
163-
_smolIdCache[id] = result;
165+
'${id.replaceAll(smolIdAllowedChars, '').take(6)}-${versionString.replaceAll(smolIdAllowedChars, '').take(9)}-${(id.hashCode + version.hashCode).abs()}';
166+
_smolIdCache[cacheKey] = result;
164167

165168
if (_smolIdCache.length > 1000) {
166169
_smolIdCache.clear();

lib/trios/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:trios/models/version.dart';
66
import 'package:trios/utils/extensions.dart';
77

88
class Constants {
9-
static const version = "1.3.0-dev05";
9+
static const version = "1.3.0-dev06";
1010
static Version currentVersion = Version.parse(version);
1111

1212
static const appName = "TriOS";

0 commit comments

Comments
 (0)