exodus-framework 2.0.99993 → 2.0.99994

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ declare class FileLibraryService extends Service {
15
15
  getFileBuffer(md5: string): Promise<Buffer>;
16
16
  deleteFile(md5: string): Promise<boolean>;
17
17
  getFileMeta(md5: string): Promise<IMetaFile>;
18
- saveAndRegisterFile(filePath: string): Promise<string>;
18
+ saveAndRegisterFile(filePath: string, temporary?: boolean): Promise<string>;
19
19
  saveAndRegisterBuffer(buffer: Buffer, originalName: string, ext: string): Promise<string>;
20
20
  getMD5FromFile(filePath: string): Promise<string>;
21
21
  getMD5FromBuffer(buffer: Buffer): string;
@@ -1 +1 @@
1
- {"version":3,"file":"FileLibrary.d.ts","sourceRoot":"","sources":["../../../src/services/file/FileLibrary.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,cAAM,kBAAmB,SAAQ,OAAO;IACtC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;IAEZ,aAAa;IAQb,OAAO;YAMN,WAAW;YA2BX,iBAAiB;IAyBxB,WAAW,CAAC,GAAG,EAAE,MAAM;IAOjB,UAAU,CAAC,GAAG,EAAE,MAAM;IAO5B,aAAa,CAAC,GAAG,EAAE,MAAM;IAOnB,UAAU,CAAC,GAAG,EAAE,MAAM;IAWtB,WAAW,CAAC,GAAG,EAAE,MAAM;IAWvB,mBAAmB,CAAC,QAAQ,EAAE,MAAM;IAmCpC,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IA2B7E,cAAc,CAAC,QAAQ,EAAE,MAAM;IAW/B,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAMxC,QAAQ,CAAC,GAAG,EAAE,MAAM;CAG5B;AAED,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"FileLibrary.d.ts","sourceRoot":"","sources":["../../../src/services/file/FileLibrary.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,cAAM,kBAAmB,SAAQ,OAAO;IACtC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;IAEZ,aAAa;IAQb,OAAO;YAMN,WAAW;YA8BX,iBAAiB;IAyBxB,WAAW,CAAC,GAAG,EAAE,MAAM;IAOjB,UAAU,CAAC,GAAG,EAAE,MAAM;IAO5B,aAAa,CAAC,GAAG,EAAE,MAAM;IAOnB,UAAU,CAAC,GAAG,EAAE,MAAM;IAWtB,WAAW,CAAC,GAAG,EAAE,MAAM;IAWvB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,UAAQ;IAyCvD,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IA2B7E,cAAc,CAAC,QAAQ,EAAE,MAAM;IAW/B,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAMxC,QAAQ,CAAC,GAAG,EAAE,MAAM;CAG5B;AAED,eAAe,kBAAkB,CAAC"}
@@ -33,6 +33,8 @@ class FileLibraryService extends _service.default {
33
33
  const files = await _fsExtra.default.readdir(this.path);
34
34
  this.log(`Carregando biblioteca de arquivos. Encontrados ${files.length} arquivos`, 'info');
35
35
  for (const file of files) {
36
+ // apenas metadados
37
+ if (!file.endsWith('.meta')) continue;
36
38
  const filePath = _path.default.join(this.path, file);
37
39
  const fileCache = new _FileCache.default(filePath);
38
40
  await fileCache.onInit();
@@ -62,7 +64,7 @@ class FileLibraryService extends _service.default {
62
64
  const md5 = await this.getMD5FromFile(itemPath);
63
65
  if (md5 && !this.cache.has(md5)) {
64
66
  //! este move o arquivo, não é preciso excluir o original
65
- await this.saveAndRegisterFile(itemPath);
67
+ await this.saveAndRegisterFile(itemPath, true);
66
68
  } else {
67
69
  await _fsExtra.default.unlink(itemPath);
68
70
  }
@@ -101,18 +103,23 @@ class FileLibraryService extends _service.default {
101
103
  * Save a file to the library and register it in the cache
102
104
  * @return MD5 hash of the saved file
103
105
  */
104
- async saveAndRegisterFile(filePath) {
106
+ async saveAndRegisterFile(filePath, temporary = false) {
105
107
  const md5 = await this.getMD5FromFile(filePath);
106
108
  if (!md5) throw new Error('Falha ao gerar o md5 do arquivo');
107
109
  if (this.isCached(md5)) return;
108
110
  const ext = this.mime.getFileExtension(filePath);
109
111
  const newFilePath = _path.default.join(this.path, `${md5}.${ext}`);
110
112
  const metaFilePath = _path.default.join(this.path, `${md5}.meta`);
113
+ let originalName = _path.default.basename(filePath);
114
+ if (temporary) {
115
+ const split = originalName.split('#');
116
+ originalName = split[split.length - 1];
117
+ }
111
118
  await _fsExtra.default.move(filePath, newFilePath, {
112
119
  overwrite: true
113
120
  });
114
121
  const metaData = {
115
- originalName: _path.default.basename(filePath),
122
+ originalName,
116
123
  extension: ext,
117
124
  size: (await _fsExtra.default.stat(newFilePath)).size,
118
125
  md5,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodus-framework",
3
- "version": "2.0.99993",
3
+ "version": "2.0.99994",
4
4
  "description": "Exodus Framework",
5
5
  "author": "jhownpaixao",
6
6
  "license": "ISC",