| 111 | } |
| 112 | |
| 113 | async done() { |
| 114 | if (this.fd != null) { |
| 115 | await fs.close(this.fd); |
| 116 | this.fd = null; |
| 117 | await this.releaseLock!(); |
| 118 | } |
| 119 | |
| 120 | if (this.id != null) { |
| 121 | uploadManager.delete(this.id); |
| 122 | } |
| 123 | |
| 124 | logger.info("Browser Uploaded File:", this.path); |
| 125 | |
| 126 | if (this.unzip) { |
| 127 | // Statistics of the number of tasks in a single instance file and the number of tasks in the entire daemon process |
| 128 | |
| 129 | globalEnv.fileTaskCount++; |
| 130 | if (this.instance) this.instance.info.fileLock++; |
| 131 | |
| 132 | try { |
| 133 | const instanceFiles = new FileManager(this.cwd); |
| 134 | await instanceFiles.unzip(this.path, path.dirname(this.path), this.zipCode); |
| 135 | logger.info("File unzipped:", this.path); |
| 136 | |
| 137 | if (this.deleteAfterUnzip) { |
| 138 | await fs.remove(this.path); |
| 139 | logger.info("Temporary zip deleted:", this.path); |
| 140 | } |
| 141 | } finally { |
| 142 | globalEnv.fileTaskCount--; |
| 143 | if (this.instance) this.instance.info.fileLock--; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | async stop() { |
| 149 | if (this.fd != null) { |