Sharp: Cant remove file after transform

Created on 30 Jan 2017  路  3Comments  路  Source: lovell/sharp

My environment
Win 7, node v6.3.0, npm 4.1.2

Sample code

let sharp = require("sharp");
let fs = require("fs");

let fromPath = "c:\\unsorted-photos\\P1300375.JPG";
let toPath = "c:\\photos\\2017\\2017_01_30\\P1300375.JPG";

sharp(fromPath)
    .resize(1600)
    .withMetadata()
    .toFile(toPath, (error, info) => {
        if (error) {
            console.log(error);
        } else {
            fs.unlinkSync(fromPath);
        }
    });

Got error

$ node test.js
vips warning: VipsJpeg: bad exif meta "exif-ifd3-GPSVersionID"
fs.js:1089
  return binding.unlink(pathModule._makeLong(path));
                 ^

Error: EBUSY: resource busy or locked, unlink 'c:\unsorted-photos\P1300375.JPG'
    at Error (native)
    at Object.fs.unlinkSync (fs.js:1089:18)
    at sharp.resize.withMetadata.toFile (C:\Work\sort-photos\test.js:14:16)

Packages versions are

$ npm list
[email protected] C:\Work\sort-photos
+-- [email protected]
| `-- [email protected]
|   `-- [email protected]
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| |   +-- [email protected]
| |   `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
+-- [email protected]
`-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | |   +-- [email protected]
  | |   +-- [email protected]
  | |   +-- [email protected]
  | |   `-- [email protected]
  | `-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  |     `-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  +-- [email protected]
  `-- [email protected]
    +-- [email protected]
    +-- [email protected]
    | +-- [email protected]
    | `-- [email protected]
    |   `-- [email protected]
    |     +-- [email protected]
    |     +-- [email protected]
    |     | `-- [email protected]
    |     +-- [email protected]
    |     `-- [email protected]
    `-- [email protected]

How can I remove file after transform?

Most helpful comment

Thanks!

sharp.cache(false);

Solved the problem for me

All 3 comments

Please see #346, #447

Thanks!

sharp.cache(false);

Solved the problem for me

Thanks!

sharp.cache(false);

Solved the problem for me

Help me, where is the "sharp.cache(false);"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

henbenla picture henbenla  路  3Comments

vermin1337 picture vermin1337  路  3Comments

kachurovskiy picture kachurovskiy  路  3Comments

janaz picture janaz  路  3Comments

jaekunchoi picture jaekunchoi  路  3Comments