Problem/Motivation

      if (!file_exists($uri) && !$this->fileSystem->saveData($data, $uri, FileExists::Replace)) {
        return FALSE;
      }

What happens if the file exists? This is hard to read, especially with the negative on it.

If there's really no better way to write this, a comment would help.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

joachim created an issue.

shank115’s picture

If I'm reading it right, when the file already exists, saveData() never gets called and the method just returns the URI as if it succeeded. So I think it basically means "only write the file if it isn't there yet".

I think it's the same as:

if (!$this->fileSystem->saveData($data, $uri, FileExists::Replace)) {
      return FALSE;
    }

If the file already existed, nothing is written and we carry on. Please correct me if I've got this wrong.