Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Client {
/// Recursively create folders
Future<void> mkdirAll(String path, [CancelToken? cancelToken]) async {
path = fixSlashes(path);

var resp = await this.c.wdMkcol(this, path, cancelToken: cancelToken);
var status = resp.statusCode;
if (status == 201 || status == 405) {
Expand All @@ -107,9 +108,10 @@ class Client {
continue;
}
sub += e + '/';

resp = await this.c.wdMkcol(this, sub, cancelToken: cancelToken);
status = resp.statusCode;
if (status != 201 && status != 405) {
if (status != 201 && status != 405 && status != 409) {
throw newResponseError(resp);
}
}
Expand Down
33 changes: 23 additions & 10 deletions lib/src/xml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class WebdavXml {
// response
list.forEach((element) {
// name
String href = findElements(element, 'href').single.text;
final hrefElements = findElements(element, 'href');
String href = hrefElements.isNotEmpty ? hrefElements.single.text : '';

// propstats
var props = findElements(element, 'propstat');
Expand All @@ -45,10 +46,12 @@ class WebdavXml {
if (findElements(propstat, 'status').single.text.contains('200')) {
// prop
for (var prop in findElements(propstat, 'prop')) {
final resourceTypeElements = findElements(prop, 'resourcetype');
// isDir
bool isDir = findElements(
findElements(prop, 'resourcetype').single, 'collection')
.isNotEmpty;
bool isDir = resourceTypeElements.isNotEmpty
? findElements(resourceTypeElements.single, 'collection')
.isNotEmpty
: false;

// skip self
if (skipSelf) {
Expand Down Expand Up @@ -80,15 +83,25 @@ class WebdavXml {

// create time
final cTimeElements = findElements(prop, 'creationdate');
DateTime? cTime = cTimeElements.isNotEmpty
? DateTime.parse(cTimeElements.single.text).toLocal()
: null;
DateTime? cTime;
try {
cTime = cTimeElements.isNotEmpty
? DateTime.parse(cTimeElements.single.text).toLocal()
: null;
} catch (e) {
cTime = null;
}

// modified time
final mTimeElements = findElements(prop, 'getlastmodified');
DateTime? mTime = mTimeElements.isNotEmpty
? str2LocalTime(mTimeElements.single.text)
: null;
DateTime? mTime;
try {
mTime = mTimeElements.isNotEmpty
? str2LocalTime(mTimeElements.single.text)
: null;
} catch (e) {
mTime = null;
}

//
var str = Uri.decodeFull(href);
Expand Down