Use const whenever possible

This commit is contained in:
Ming Ming 2022-01-20 03:51:08 +08:00
parent 2dcfe4a261
commit 2f4adeafa5
2 changed files with 5 additions and 3 deletions

View file

@ -428,7 +428,7 @@ class FileCachedDataSource implements FileDataSource {
await _cacheResult(account, f, remote);
if (shouldCheckCache) {
// update our local touch token to match the remote one
final tokenManager = TouchTokenManager();
const tokenManager = TouchTokenManager();
try {
await tokenManager.setLocalToken(
account, f, cacheManager.remoteTouchToken);
@ -500,7 +500,7 @@ class FileCachedDataSource implements FileDataSource {
// generate a new random token
final token = const Uuid().v4().replaceAll("-", "");
final tokenManager = TouchTokenManager();
const tokenManager = TouchTokenManager();
final dir = File(path: path.dirname(f.path));
await tokenManager.setLocalToken(account, dir, token);
final fileRepo = FileRepo(this);
@ -739,7 +739,7 @@ class _CacheManager {
final touchPath =
"${remote_storage_util.getRemoteTouchDir(account)}/${f.strippedPath}";
final fileRepo = FileRepo(FileCachedDataSource(appDb));
final tokenManager = TouchTokenManager();
const tokenManager = TouchTokenManager();
String? remoteToken;
try {
remoteToken = await tokenManager.getRemoteToken(fileRepo, account, f);

View file

@ -22,6 +22,8 @@ import 'package:nc_photos/use_case/remove.dart';
/// token requires downloading a file from the server so you may want to avoid
/// doing it on every query
class TouchTokenManager {
const TouchTokenManager();
Future<void> setRemoteToken(
FileRepo fileRepo, Account account, File file, String? token) async {
_log.info(