Page MenuHomePhabricator

[native] Implement filesystem media cache
ClosedPublic

Authored by bartek on Mar 30 2023, 7:03 AM.
Tags
None
Referenced Files
F1746286: D7252.diff
Mon, May 13, 2:21 PM
Unknown Object (File)
Sun, May 12, 12:59 AM
Unknown Object (File)
Tue, May 7, 9:11 AM
Unknown Object (File)
Sun, May 5, 12:04 AM
Unknown Object (File)
Sat, Apr 27, 8:58 PM
Unknown Object (File)
Sat, Apr 27, 8:58 PM
Unknown Object (File)
Sat, Apr 27, 8:58 PM
Unknown Object (File)
Sat, Apr 27, 8:58 PM
Subscribers

Details

Summary

This diff implements native methods to manage media cache stored in filesystem: the tmp_dir/media-cache directory.

Depends on D7251

Test Plan

Tested together with parent diff - saved some files to cache and then retrieved it. It is possible to print the cache path and open it with Finder to inspect what files are inside.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Mar 30 2023, 9:30 AM
ashoat added inline comments.
lib/media/file-utils.js
203 ↗(On Diff #24388)

Should the first param be a RegExp to make sure it doesn't replace other parts of the filename? Not sure this works, but something like

new RegExp(`.${extension}$`)
native/media/media-cache.js
1 ↗(On Diff #24388)

Nit: add extra newline here

30 ↗(On Diff #24388)

Nit: add newline here

33–34 ↗(On Diff #24388)

Nit

69 ↗(On Diff #24388)

Can we extract this RegExp object and assign it to a variable in the global scope to avoid recreating it every time?

This revision is now accepted and ready to land.Mar 30 2023, 4:35 PM
lib/media/file-utils.js
203 ↗(On Diff #24388)

Good point

Please escape the . character in the RegExp before landing! Sorry I didn't notice this in my suggestion

lib/media/file-utils.js
203

The . character here matches anything, so eg. if you mean to replace test.blah -> test`, you could accidentally replace test.zblah -> test..

I think we can escape the . character to avoid this

This revision was automatically updated to reflect the committed changes.