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] Prevent FS write from draining Resources content #22

Merged
merged 6 commits into from
Jan 31, 2019

Conversation

RandomByte
Copy link
Member

@RandomByte RandomByte commented Jul 10, 2018

Previously, when writing to an FS-Adapter, a Resources content stream
would be drained, making it impossible to access a Resources content
again.

With this change, by default a Resources content will be buffered while
draining its content stream.

An optional 'drain' parameter can be supplied to skip buffering to lower
the memory demand of the operation in cases where further access to the
resource content is not required.

Alternatively, an optional 'readOnly' parameter can be supplied to skip
buffering and instead create a new readable stream of the written file.
The file will be written with '444' (read only) permissions. This can
also help reducing memory usage.

Add a pessimistic check for drained content streams.

Refactor FS- and memory adapter unit tests.

Resolves blocker for SAP/ui5-builder#42

@RandomByte RandomByte added the bug Something isn't working label Jul 10, 2018
@SAP SAP deleted a comment from coveralls Jul 10, 2018
@RandomByte RandomByte force-pushed the fix/write-should-not-drain-stream branch from 2b66262 to 3a7c6a7 Compare July 17, 2018 15:23
@RandomByte RandomByte force-pushed the fix/write-should-not-drain-stream branch 3 times, most recently from 56ba0ba to efd6928 Compare August 20, 2018 15:21
@SAP SAP deleted a comment from coveralls Aug 20, 2018
@RandomByte RandomByte force-pushed the fix/write-should-not-drain-stream branch from efd6928 to 58777e8 Compare August 20, 2018 15:28
@RandomByte RandomByte force-pushed the fix/write-should-not-drain-stream branch 2 times, most recently from d24a55e to 36b8d29 Compare January 31, 2019 15:05
Previously, when writing to an FS-Adapter, a Resources content stream
would be drained, making it impossible to access a Resources content
again.

With this change, by default a Resources content will be buffered while
draining its content stream.

An optional 'drain' parameter can be supplied to skip buffering to lower
the memory demand of the operation in cases where further access to the
resource content is not required.

Alternatively, an optional 'readOnly' parameter can be supplied to skip
buffering and instead create a new readable stream of the written file.
The file will be written with '444' (read only) permissions. This can
also help reducing memory usage.

Add a pessimistic check for drained content streams.

Refactor FS- and memory adapter unit tests.
@RandomByte RandomByte force-pushed the fix/write-should-not-drain-stream branch from 36b8d29 to 65da854 Compare January 31, 2019 15:20
@RandomByte
Copy link
Member Author

Ready for review

lib/Resource.js Outdated Show resolved Hide resolved
lib/Resource.js Show resolved Hide resolved
lib/Resource.js Show resolved Hide resolved
lib/adapters/FileSystem.js Outdated Show resolved Hide resolved
lib/AbstractReaderWriter.js Show resolved Hide resolved
@CLAassistant
Copy link

CLAassistant commented Jan 31, 2019

CLA assistant check
All committers have signed the CLA.

@RandomByte
Copy link
Member Author

For future reference: Some more clarification on the issue this PR resolves can be found here: SAP/ui5-builder#42 (comment)

@RandomByte RandomByte merged commit 7b75f04 into master Jan 31, 2019
@RandomByte RandomByte deleted the fix/write-should-not-drain-stream branch January 31, 2019 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants