Skip to content

Commit

Permalink
Add draft concept for sync services
Browse files Browse the repository at this point in the history
  • Loading branch information
janheinrichmerker committed Nov 7, 2020
1 parent 84a3611 commit 2deaa93
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/sync/file.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/cupertino.dart';

abstract class RemoteFile {
/// File path.
@required
String path;

/// File content length or folder size
@required
int size;

// Date of last modification.
@required
DateTime lastModified;

/// Creation date of the file.
@required
DateTime createdDate;

/// Returns the decoded name of the file / folder without the whole path
@required
String get name {
// normalised path (remove trailing slash)
final end = path.endsWith('/') ? path.length - 1 : path.length;
return Uri.parse(path, 0, end).pathSegments.last;
}

/// Whether the file is a directory.
@required
bool isDirectory;
}
18 changes: 18 additions & 0 deletions lib/sync/sync.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/widgets.dart';
import 'package:txt/sync/file.dart';

abstract class SyncService {
Future<void> authorize(BuildContext context);

Future<String> getAccountName();

Future<List<RemoteFile>> listFolder(String path);

Future<void> upload(String localPath, String remotePath);

Future<void> download(String remotePath, String localPath);
}

Future<void> sync(String localPath, String remotePath) async {
throw UnimplementedError();
}

0 comments on commit 2deaa93

Please sign in to comment.