Backed out 3 changesets (bug 1741247, bug 1723082, bug 1736175) for causing PathUtils.normalize failures.

CLOSED TREE

Backed out changeset 55165cf4b7bb (bug 1736175)
Backed out changeset 492f5ca3b592 (bug 1723082)
Backed out changeset ce199e98a0c5 (bug 1741247)
This commit is contained in:
Alexandru Michis 2021-11-17 03:12:07 +02:00
Родитель 446bae08de
Коммит 2d0c990efe
5 изменённых файлов: 11 добавлений и 28 удалений

Просмотреть файл

@ -24,9 +24,7 @@
[ChromeOnly, Exposed=(Window, Worker)]
namespace IOUtils {
/**
* Reads up to |opts.maxBytes| of the file at |path| according to |opts|.
*
* NB: The maximum file size that can be read is UINT32_MAX.
* Reads up to |maxBytes| of the file at |path| according to |opts|.
*
* @param path An absolute file path.
*
@ -38,8 +36,6 @@ namespace IOUtils {
* Reads the UTF-8 text file located at |path| and returns the decoded
* contents as a |DOMString|.
*
* NB: The maximum file size that can be read is UINT32_MAX.
*
* @param path An absolute file path.
*
* @return Resolves with the file contents encoded as a string, otherwise
@ -50,8 +46,6 @@ namespace IOUtils {
* Read the UTF-8 text file located at |path| and return the contents
* parsed as JSON into a JS value.
*
* NB: The maximum file size that can be read is UINT32_MAX.
*
* @param path An absolute path.
*
* @return Resolves with the contents of the file parsed as JSON.

Просмотреть файл

@ -106,9 +106,6 @@ The following is a detailed comparison with examples of the methods and options
`IOUtils` provides the following methods to read data from a file. Like
`OS.File`, they accept an `options` dictionary.
Note: The maximum file size that can be read is `UINT32_MAX` bytes. Attempting
to read a file larger will result in a `NotReadableError`.
```idl
Promise<Uint8Array> read(DOMString path, ...);

Просмотреть файл

@ -240,8 +240,8 @@ static void RejectJSPromise(Promise* aPromise, const IOUtils::IOError& aError) {
aPromise->MaybeRejectWithAbortError(errMsg.refOr("Operation aborted"_ns));
break;
default:
aPromise->MaybeRejectWithUnknownError(FormatErrorMessage(
aError.Code(), errMsg.refOr("Unexpected error"_ns).get()));
aPromise->MaybeRejectWithUnknownError(
errMsg.refOr(FormatErrorMessage(aError.Code(), "Unexpected error")));
}
}
@ -896,13 +896,9 @@ Result<IOUtils::JsBuffer, IOUtils::IOError> IOUtils::ReadSync(
// Read the file from disk.
uint32_t totalRead = 0;
while (totalRead != bufSize) {
// Read no more than INT32_MAX on each call to stream->Read, otherwise it
// returns an error.
uint32_t bytesToReadThisChunk =
std::min<uint32_t>(bufSize - totalRead, INT32_MAX);
uint32_t bytesRead = 0;
if (nsresult rv =
stream->Read(toRead.Elements(), bytesToReadThisChunk, &bytesRead);
stream->Read(toRead.Elements(), bufSize - totalRead, &bytesRead);
NS_FAILED(rv)) {
return Err(IOError(rv).WithMessage(
"Encountered an unexpected error while reading file(%s)",

Просмотреть файл

@ -207,7 +207,7 @@ function LegacyTracker(name, engine) {
this._ignored = [];
this.file = this.name;
this._storage = new JSONFile({
path: Utils.jsonFilePath("changes", `${this.file}.json`),
path: Utils.jsonFilePath("changes/" + this.file),
dataPostProcessor: json => this._dataPostProcessor(json),
beforeSave: () => this._beforeSave(),
});
@ -767,13 +767,13 @@ function SyncEngine(name, service) {
this._log.debug("Engine constructed");
this._toFetchStorage = new JSONFile({
path: Utils.jsonFilePath("toFetch", `${this.name}.json`),
path: Utils.jsonFilePath("toFetch/" + this.name),
dataPostProcessor: json => this._metadataPostProcessor(json),
beforeSave: () => this._beforeSaveMetadata(),
});
this._previousFailedStorage = new JSONFile({
path: Utils.jsonFilePath("failed", `${this.name}.json`),
path: Utils.jsonFilePath("failed/" + this.name),
dataPostProcessor: json => this._metadataPostProcessor(json),
beforeSave: () => this._beforeSaveMetadata(),
});

Просмотреть файл

@ -348,13 +348,9 @@ var Utils = {
).slice(0, SYNC_KEY_DECODED_LENGTH);
},
jsonFilePath(...args) {
return PathUtils.normalize(
PathUtils.join(
Services.dirsvc.get("ProfD", Ci.nsIFile).path,
"weave",
...args
)
jsonFilePath(filePath) {
return OS.Path.normalize(
OS.Path.join(OS.Constants.Path.profileDir, "weave", filePath + ".json")
);
},
@ -372,7 +368,7 @@ var Utils = {
* Promise resolved when the write has been performed.
*/
async jsonLoad(filePath, that) {
let path = Utils.jsonFilePath(`${filePath}.json`);
let path = Utils.jsonFilePath(filePath);
if (that._log && that._log.trace) {
that._log.trace("Loading json from disk: " + filePath);