mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Refactor: rename fn argument
This commit is contained in:
parent
a20becfec5
commit
1a328b2a6d
2 changed files with 12 additions and 12 deletions
|
@ -609,8 +609,8 @@ class FileRepo {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class FileDataSource {
|
abstract class FileDataSource {
|
||||||
/// List all files under [f]
|
/// List all files under [dir]
|
||||||
Future<List<File>> list(Account account, File f);
|
Future<List<File>> list(Account account, File dir);
|
||||||
|
|
||||||
/// List a single file [f]
|
/// List a single file [f]
|
||||||
Future<File> listSingle(Account account, File f);
|
Future<File> listSingle(Account account, File f);
|
||||||
|
|
|
@ -27,12 +27,12 @@ class FileWebdavDataSource implements FileDataSource {
|
||||||
@override
|
@override
|
||||||
list(
|
list(
|
||||||
Account account,
|
Account account,
|
||||||
File f, {
|
File dir, {
|
||||||
int? depth,
|
int? depth,
|
||||||
}) async {
|
}) async {
|
||||||
_log.fine("[list] ${f.path}");
|
_log.fine("[list] ${dir.path}");
|
||||||
final response = await Api(account).files().propfind(
|
final response = await Api(account).files().propfind(
|
||||||
path: f.path,
|
path: dir.path,
|
||||||
depth: depth,
|
depth: depth,
|
||||||
getlastmodified: 1,
|
getlastmodified: 1,
|
||||||
resourcetype: 1,
|
resourcetype: 1,
|
||||||
|
@ -409,7 +409,7 @@ class FileCachedDataSource implements FileDataSource {
|
||||||
}) : _appDbSrc = FileAppDbDataSource(appDb);
|
}) : _appDbSrc = FileAppDbDataSource(appDb);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
list(Account account, File f) async {
|
list(Account account, File dir) async {
|
||||||
final cacheManager = _CacheManager(
|
final cacheManager = _CacheManager(
|
||||||
appDb: appDb,
|
appDb: appDb,
|
||||||
appDbSrc: _appDbSrc,
|
appDbSrc: _appDbSrc,
|
||||||
|
@ -417,21 +417,21 @@ class FileCachedDataSource implements FileDataSource {
|
||||||
shouldCheckCache: shouldCheckCache,
|
shouldCheckCache: shouldCheckCache,
|
||||||
forwardCacheManager: forwardCacheManager,
|
forwardCacheManager: forwardCacheManager,
|
||||||
);
|
);
|
||||||
final cache = await cacheManager.list(account, f);
|
final cache = await cacheManager.list(account, dir);
|
||||||
if (cacheManager.isGood) {
|
if (cacheManager.isGood) {
|
||||||
return cache!;
|
return cache!;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no cache or outdated
|
// no cache or outdated
|
||||||
try {
|
try {
|
||||||
final remote = await _remoteSrc.list(account, f);
|
final remote = await _remoteSrc.list(account, dir);
|
||||||
await _cacheResult(account, f, remote);
|
await _cacheResult(account, dir, remote);
|
||||||
if (shouldCheckCache) {
|
if (shouldCheckCache) {
|
||||||
// update our local touch token to match the remote one
|
// update our local touch token to match the remote one
|
||||||
const tokenManager = TouchTokenManager();
|
const tokenManager = TouchTokenManager();
|
||||||
try {
|
try {
|
||||||
await tokenManager.setLocalToken(
|
await tokenManager.setLocalToken(
|
||||||
account, f, cacheManager.remoteTouchToken);
|
account, dir, cacheManager.remoteTouchToken);
|
||||||
} catch (e, stacktrace) {
|
} catch (e, stacktrace) {
|
||||||
_log.shout("[list] Failed while setLocalToken", e, stacktrace);
|
_log.shout("[list] Failed while setLocalToken", e, stacktrace);
|
||||||
// ignore error
|
// ignore error
|
||||||
|
@ -444,8 +444,8 @@ class FileCachedDataSource implements FileDataSource {
|
||||||
return remote;
|
return remote;
|
||||||
} on ApiException catch (e) {
|
} on ApiException catch (e) {
|
||||||
if (e.response.statusCode == 404) {
|
if (e.response.statusCode == 404) {
|
||||||
_log.info("[list] File removed: $f");
|
_log.info("[list] File removed: $dir");
|
||||||
_appDbSrc.remove(account, f);
|
_appDbSrc.remove(account, dir);
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
rethrow;
|
rethrow;
|
||||||
|
|
Loading…
Reference in a new issue