1
1
part of '../neon_files.dart' ;
2
2
3
3
abstract interface class FilesBlocEvents {
4
- void uploadFile (final List < String > path , final String localPath);
4
+ void uploadFile (final PathUri uri , final String localPath);
5
5
6
- void syncFile (final List < String > path );
6
+ void syncFile (final PathUri uri );
7
7
8
- void openFile (final List < String > path , final String etag, final String ? mimeType);
8
+ void openFile (final PathUri uri , final String etag, final String ? mimeType);
9
9
10
- void shareFileNative (final List < String > path , final String etag);
10
+ void shareFileNative (final PathUri uri , final String etag);
11
11
12
- void delete (final List < String > path );
12
+ void delete (final PathUri uri );
13
13
14
- void rename (final List < String > path , final String name);
14
+ void rename (final PathUri uri , final String name);
15
15
16
- void move (final List < String > path , final List < String > destination);
16
+ void move (final PathUri uri , final PathUri destination);
17
17
18
- void copy (final List < String > path , final List < String > destination);
18
+ void copy (final PathUri uri , final PathUri destination);
19
19
20
- void addFavorite (final List < String > path );
20
+ void addFavorite (final PathUri uri );
21
21
22
- void removeFavorite (final List < String > path );
22
+ void removeFavorite (final PathUri uri );
23
23
}
24
24
25
25
abstract interface class FilesBlocStates {
@@ -58,35 +58,35 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
58
58
BehaviorSubject <List <FilesTask >> tasks = BehaviorSubject <List <FilesTask >>.seeded ([]);
59
59
60
60
@override
61
- void addFavorite (final List < String > path ) {
61
+ void addFavorite (final PathUri uri ) {
62
62
wrapAction (
63
63
() async => account.client.webdav.proppatch (
64
- Uri (pathSegments : path) ,
64
+ uri ,
65
65
set : WebDavProp (ocfavorite: 1 ),
66
66
),
67
67
);
68
68
}
69
69
70
70
@override
71
- void copy (final List < String > path , final List < String > destination) {
72
- wrapAction (() async => account.client.webdav.copy (Uri (pathSegments : path), Uri (pathSegments : destination) ));
71
+ void copy (final PathUri uri , final PathUri destination) {
72
+ wrapAction (() async => account.client.webdav.copy (uri, destination));
73
73
}
74
74
75
75
@override
76
- void delete (final List < String > path ) {
77
- wrapAction (() async => account.client.webdav.delete (Uri (pathSegments : path) ));
76
+ void delete (final PathUri uri ) {
77
+ wrapAction (() async => account.client.webdav.delete (uri ));
78
78
}
79
79
80
80
@override
81
- void move (final List < String > path , final List < String > destination) {
82
- wrapAction (() async => account.client.webdav.move (Uri (pathSegments : path), Uri (pathSegments : destination) ));
81
+ void move (final PathUri uri , final PathUri destination) {
82
+ wrapAction (() async => account.client.webdav.move (uri, destination));
83
83
}
84
84
85
85
@override
86
- void openFile (final List < String > path , final String etag, final String ? mimeType) {
86
+ void openFile (final PathUri uri , final String etag, final String ? mimeType) {
87
87
wrapAction (
88
88
() async {
89
- final file = await _cacheFile (path , etag);
89
+ final file = await _cacheFile (uri , etag);
90
90
91
91
final result = await OpenFile .open (file.path, type: mimeType);
92
92
if (result.type != ResultType .done) {
@@ -98,10 +98,10 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
98
98
}
99
99
100
100
@override
101
- void shareFileNative (final List < String > path , final String etag) {
101
+ void shareFileNative (final PathUri uri , final String etag) {
102
102
wrapAction (
103
103
() async {
104
- final file = await _cacheFile (path , etag);
104
+ final file = await _cacheFile (uri , etag);
105
105
106
106
await Share .shareXFiles ([XFile (file.path)]);
107
107
},
@@ -115,52 +115,52 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
115
115
}
116
116
117
117
@override
118
- void removeFavorite (final List < String > path ) {
118
+ void removeFavorite (final PathUri uri ) {
119
119
wrapAction (
120
120
() async => account.client.webdav.proppatch (
121
- Uri (pathSegments : path) ,
121
+ uri ,
122
122
set : WebDavProp (ocfavorite: 0 ),
123
123
),
124
124
);
125
125
}
126
126
127
127
@override
128
- void rename (final List < String > path , final String name) {
128
+ void rename (final PathUri uri , final String name) {
129
129
wrapAction (
130
130
() async => account.client.webdav.move (
131
- Uri (pathSegments : path) ,
132
- Uri (pathSegments : List . from (path)..last = name),
131
+ uri ,
132
+ uri. rename ( name),
133
133
),
134
134
);
135
135
}
136
136
137
137
@override
138
- void syncFile (final List < String > path ) {
138
+ void syncFile (final PathUri uri ) {
139
139
wrapAction (
140
140
() async {
141
141
final file = File (
142
- p.join (
142
+ p.joinAll ([
143
143
await NeonPlatform .instance.userAccessibleAppDataPath,
144
144
account.humanReadableID,
145
145
'files' ,
146
- path. join ( Platform .pathSeparator) ,
147
- ),
146
+ ...uri.pathSegments ,
147
+ ] ),
148
148
);
149
149
if (! file.parent.existsSync ()) {
150
150
file.parent.createSync (recursive: true );
151
151
}
152
- await _downloadFile (path , file);
152
+ await _downloadFile (uri , file);
153
153
},
154
154
disableTimeout: true ,
155
155
);
156
156
}
157
157
158
158
@override
159
- void uploadFile (final List < String > path , final String localPath) {
159
+ void uploadFile (final PathUri uri , final String localPath) {
160
160
wrapAction (
161
161
() async {
162
162
final task = FilesUploadTask (
163
- path : path ,
163
+ uri : uri ,
164
164
file: File (localPath),
165
165
);
166
166
tasks.add (tasks.value..add (task));
@@ -171,27 +171,27 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
171
171
);
172
172
}
173
173
174
- Future <File > _cacheFile (final List < String > path , final String etag) async {
174
+ Future <File > _cacheFile (final PathUri uri , final String etag) async {
175
175
final cacheDir = await getApplicationCacheDirectory ();
176
- final file = File (p.join (cacheDir.path, 'files' , etag.replaceAll ('"' , '' ), path.last ));
176
+ final file = File (p.join (cacheDir.path, 'files' , etag.replaceAll ('"' , '' ), uri.name ));
177
177
178
178
if (! file.existsSync ()) {
179
- debugPrint ('Downloading ${ Uri ( pathSegments : path )} since it does not exist' );
179
+ debugPrint ('Downloading $uri since it does not exist' );
180
180
if (! file.parent.existsSync ()) {
181
181
await file.parent.create (recursive: true );
182
182
}
183
- await _downloadFile (path , file);
183
+ await _downloadFile (uri , file);
184
184
}
185
185
186
186
return file;
187
187
}
188
188
189
189
Future <void > _downloadFile (
190
- final List < String > path ,
190
+ final PathUri uri ,
191
191
final File file,
192
192
) async {
193
193
final task = FilesDownloadTask (
194
- path : path ,
194
+ uri : uri ,
195
195
file: file,
196
196
);
197
197
tasks.add (tasks.value..add (task));
@@ -200,12 +200,12 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta
200
200
}
201
201
202
202
FilesBrowserBloc getNewFilesBrowserBloc ({
203
- final List < String > ? initialPath ,
203
+ final PathUri ? initialUri ,
204
204
}) =>
205
205
FilesBrowserBloc (
206
206
options,
207
207
account,
208
- initialPath: initialPath ,
208
+ initialPath: initialUri ,
209
209
);
210
210
211
211
void _downloadParallelismListener () {
0 commit comments