Skip to content

Commit

Permalink
fix: files with no mime type cause sync to crash (#2963)
Browse files Browse the repository at this point in the history
* Fix files with no mime type cause sync to crash

---------

Co-authored-by: abraunegg <[email protected]>
  • Loading branch information
celsopalmeiraneto and abraunegg authored Nov 12, 2024
1 parent a035ba9 commit 6024d30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -1345,13 +1345,11 @@ class SyncEngine {
}

// Microsoft OneDrive OneNote file objects will report as files but have 'application/msonenote' as their mime type
// Is there a 'file' JSON element?
if ("file" in onedriveJSONItem) {
if (isMicrosoftOneNoteMimeType1(onedriveJSONItem)) {
// Log that this was skipped as this was a Microsoft OneNote item and unsupported
if (verboseLogging) {addLogEntry("Skipping path - The Microsoft OneNote Notebook File '" ~ generatePathFromJSONData(onedriveJSONItem) ~ "' is not supported by this client", ["verbose"]);}
discardDeltaJSONItem = true;
}
// Is there a 'file' JSON element and it has a 'mimeType' element and the mimeType is 'application/msonenote'
if (isItemFile(onedriveJSONItem) && hasMimeType(onedriveJSONItem) && isMicrosoftOneNoteMimeType1(onedriveJSONItem)) {
// Log that this was skipped as this was a Microsoft OneNote item and unsupported
if (verboseLogging) {addLogEntry("Skipping path - The Microsoft OneNote Notebook File '" ~ generatePathFromJSONData(onedriveJSONItem) ~ "' is not supported by this client", ["verbose"]);}
discardDeltaJSONItem = true;
}

// If we are not self-generating a /delta response, check this initial /delta JSON bundle item against the basic checks
Expand Down
4 changes: 4 additions & 0 deletions src/util.d
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,10 @@ bool hasId(JSONValue item) {
return ("id" in item) != null;
}

bool hasMimeType(const ref JSONValue item) {
return ("mimeType" in item["file"]) != null;
}

bool hasQuota(JSONValue item) {
return ("quota" in item) != null;
}
Expand Down

0 comments on commit 6024d30

Please sign in to comment.