Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create a copy for CODAP v3 #356

Merged
merged 2 commits into from
Feb 21, 2024
Merged

fix: create a copy for CODAP v3 #356

merged 2 commits into from
Feb 21, 2024

Conversation

kswenson
Copy link
Member

@kswenson kswenson commented Feb 20, 2024

In #354, the CloudContent.getClientContent() function was changed from:

  getClientContent() {
    return this.content.content ?? this.content
  }

to

  getClientContent() {
    return CloudContent.wrapFileContent
            ? this.content.content
            : this.content
  }

under the mistaken assumption that the CloudContent.wrapFileContent setting was a reliable indicator of whether the content in question was wrapped in CFM metadata or not. It turns out that the content is always wrapped internally by the CFM--the CloudContent.wrapFileContent setting merely determines whether it should be saved to file/disk in its wrapped or unwrapped form. The problem with the original form of the test is that some clients, e.g. CODAP v3, have an internal content property which results in getClientContent() returning the interior content in error. The proper fix from this PR is:

  getClientContent() {
    // if we can specifically identify client content, then return it
    if (CloudContent.isClientContent(this.content?.content)) return this.content.content
    if (CloudContent.isClientContent(this.content)) return this.content
    // otherwise, assume that a nested `content` property means we are wrapped
    return this.content?.content
            ? this.content.content
            : this.content
  }

The rest of the changes in this PR are additional comments, tests, and minor refactoring to make all of this a bit clearer.

@kswenson kswenson requested review from dougmartin and eireland and removed request for dougmartin February 20, 2024 22:38
Copy link
Contributor

@eireland eireland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@kswenson kswenson merged commit 7764738 into master Feb 21, 2024
2 checks passed
@kswenson kswenson deleted the support-codap-v3-copy branch February 21, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants