Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# screenshot-basic for FiveM

> **Patched fork — DeprecationWarning [DEP0005]**
>
> The `formidable@1.2.2` dependency (pulled in by `koa-body`, used to parse
> multipart uploads on the server side) uses the old `new Buffer()` constructor,
> which emits `(node) [DEP0005] DeprecationWarning: Buffer() is deprecated`
> on every screenshot upload. It is harmless, but it clutters the logs.
>
> Because the faulty code is in a **dependency** (`node_modules/`, regenerated
> on every `yarn install`), it cannot be permanently fixed “in place”. This
> fork therefore uses **[patch-package](https://github.com/ds300/patch-package)**:
>
> - `patches/formidable+1.2.2.patch` replaces `new Buffer(n)` → `Buffer.alloc(n)`
> and `new Buffer(str, 'base64')` → `Buffer.from(str, 'base64')`.
> - The `"postinstall": "patch-package"` hook (in `package.json`) **automatically
> reapplies** the patch after each `yarn install` / `npm install`, so it
> survives reinstalls and rebuilds (webpack then bundles the patched
> formidable → no more warning).
>
> Nothing else about the original behavior is changed.

## Description

screenshot-basic is a basic resource for making screenshots of clients' game render targets using FiveM. It uses the same backing
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "patch-package"
},
"author": "",
"license": "MIT",
Expand All @@ -23,6 +24,8 @@
"koa-body": "^4.0.6",
"koa-router": "^7.4.0",
"mv": "^2.1.1",
"patch-package": "^8.0.1",
"postinstall-postinstall": "^2.1.0",
"ts-loader": "^5.3.3",
"typescript": "3.2.2",
"uuid": "^3.3.2",
Expand Down
36 changes: 36 additions & 0 deletions patches/formidable+1.2.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/node_modules/formidable/lib/incoming_form.js b/node_modules/formidable/lib/incoming_form.js
index dbd920b..4e8c962 100644
--- a/node_modules/formidable/lib/incoming_form.js
+++ b/node_modules/formidable/lib/incoming_form.js
@@ -403,12 +403,12 @@ IncomingForm.prototype._initMultipart = function(boundary) {
can be divided vy 3.
*/
var offset = parseInt(part.transferBuffer.length / 4, 10) * 4;
- part.emit('data', new Buffer(part.transferBuffer.substring(0, offset), 'base64'));
+ part.emit('data', Buffer.from(part.transferBuffer.substring(0, offset), 'base64'));
part.transferBuffer = part.transferBuffer.substring(offset);
};

parser.onPartEnd = function() {
- part.emit('data', new Buffer(part.transferBuffer, 'base64'));
+ part.emit('data', Buffer.from(part.transferBuffer, 'base64'));
part.emit('end');
};
break;
diff --git a/node_modules/formidable/lib/multipart_parser.js b/node_modules/formidable/lib/multipart_parser.js
index 36de2b0..071d205 100644
--- a/node_modules/formidable/lib/multipart_parser.js
+++ b/node_modules/formidable/lib/multipart_parser.js
@@ -57,10 +57,10 @@ MultipartParser.stateToString = function(stateNumber) {
};

MultipartParser.prototype.initWithBoundary = function(str) {
- this.boundary = new Buffer(str.length+4);
+ this.boundary = Buffer.alloc(str.length+4);
this.boundary.write('\r\n--', 0);
this.boundary.write(str, 4);
- this.lookbehind = new Buffer(this.boundary.length+8);
+ this.lookbehind = Buffer.alloc(this.boundary.length+8);
this.state = S.START;

this.boundaryChars = {};