Skip to content

Commit

Permalink
Do not add a new line if file storage mode append but existing file w…
Browse files Browse the repository at this point in the history
…as empty
  • Loading branch information
Toflar committed Jul 7, 2015
1 parent 852733f commit cd07d51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Notification Center Changelog
===========================

Version 1.3.0 (2015-??-??)
---------------------------------

### Fixed
- Do not add a new line if file storage mode append but existing file was empty


Version 1.3.0-rc1 (2015-07-07)
---------------------------------

Expand Down
11 changes: 9 additions & 2 deletions library/NotificationCenter/Gateway/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ protected function saveToLocal($strFileName, $strContent, $strStorageMode)

$objFile = new \File($this->objModel->file_path . '/' . $strFileName);

if ($strStorageMode === self::FILE_STORAGE_APPEND) {
// Don't start with a newline
if ($strStorageMode === self::FILE_STORAGE_APPEND
&& $objFile->exists()
&& $objFile->getContent() !== ''
) {
$strContent = $objFile->getContent() . "\n" . $strContent;
}

Expand Down Expand Up @@ -223,7 +227,10 @@ protected function saveToFTP($strFileName, $strContent, $strStorageMode)
$fileContents = ob_get_contents();
ob_end_clean();

$strContent .= $fileContents . "\n" . $strContent;
// Don't start with a newline
if ($fileContents !== '') {
$strContent .= $fileContents . "\n" . $strContent;
}
}

// Write content to temporary file
Expand Down

0 comments on commit cd07d51

Please sign in to comment.