A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/04bb6778e5 below:

move `ToNamespacedPath` call of webstorage · nodejs/node@04bb677 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+19

-9

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+19

-9

lines changed Original file line number Diff line number Diff line change

@@ -6,7 +6,6 @@ const { ERR_INVALID_ARG_VALUE } = require('internal/errors').codes;

6 6

const { getOptionValue } = require('internal/options');

7 7

const { emitExperimentalWarning } = require('internal/util');

8 8

const { kConstructorKey, Storage } = internalBinding('webstorage');

9 -

const { resolve, toNamespacedPath } = require('path');

10 9

const { getValidatedPath } = require('internal/fs/utils');

11 10

const kInMemoryPath = ':memory:';

12 11

@@ -25,16 +24,15 @@ ObjectDefineProperties(module.exports, {

25 24

enumerable: true,

26 25

get() {

27 26

if (lazyLocalStorage === undefined) {

28 -

let location = getOptionValue('--localstorage-file');

27 +

const location = getOptionValue('--localstorage-file');

29 28 30 29

if (location === '') {

31 30

throw new ERR_INVALID_ARG_VALUE('--localstorage-file',

32 31

location,

33 32

'is an invalid localStorage location');

34 33

}

35 34 36 -

location = toNamespacedPath(resolve(getValidatedPath(location)));

37 -

lazyLocalStorage = new Storage(kConstructorKey, location);

35 +

lazyLocalStorage = new Storage(kConstructorKey, getValidatedPath(location));

38 36

}

39 37 40 38

return lazyLocalStorage;

Original file line number Diff line number Diff line change

@@ -6,6 +6,7 @@

6 6

#include "node.h"

7 7

#include "node_errors.h"

8 8

#include "node_mem-inl.h"

9 +

#include "path.h"

9 10

#include "sqlite3.h"

10 11

#include "util-inl.h"

11 12

@@ -76,13 +77,14 @@ static void ThrowQuotaExceededException(Local<Context> context) {

76 77

isolate->ThrowException(exception);

77 78

}

78 79 79 -

Storage::Storage(Environment* env, Local<Object> object, Local<String> location)

80 +

Storage::Storage(Environment* env,

81 +

Local<Object> object,

82 +

std::string_view location)

80 83

: BaseObject(env, object) {

81 84

MakeWeak();

82 -

Utf8Value utf8_location(env->isolate(), location);

83 85

symbols_.Reset(env->isolate(), Map::New(env->isolate()));

84 86

db_ = nullptr;

85 -

location_ = utf8_location.ToString();

87 +

location_ = std::string(location);

86 88

}

87 89 88 90

Storage::~Storage() {

@@ -209,7 +211,15 @@ void Storage::New(const FunctionCallbackInfo<Value>& args) {

209 211 210 212

CHECK(args.IsConstructCall());

211 213

CHECK(args[1]->IsString());

212 -

new Storage(env, args.This(), args[1].As<String>());

214 + 215 +

BufferValue location(env->isolate(), args[1]);

216 +

CHECK_NOT_NULL(*location);

217 +

// Only call namespaced path if the location is not "in memory".

218 +

if (location.ToStringView() != kInMemoryPath) {

219 +

ToNamespacedPath(env, &location);

220 +

}

221 + 222 +

new Storage(env, args.This(), location.ToStringView());

213 223

}

214 224 215 225

void Storage::Clear() {

Original file line number Diff line number Diff line change

@@ -23,11 +23,13 @@ struct stmt_deleter {

23 23

};

24 24

using stmt_unique_ptr = std::unique_ptr<sqlite3_stmt, stmt_deleter>;

25 25 26 +

static constexpr std::string_view kInMemoryPath = ":memory:";

27 + 26 28

class Storage : public BaseObject {

27 29

public:

28 30

Storage(Environment* env,

29 31

v8::Local<v8::Object> object,

30 -

v8::Local<v8::String> location);

32 +

std::string_view location);

31 33

void MemoryInfo(MemoryTracker* tracker) const override;

32 34

static void New(const v8::FunctionCallbackInfo<v8::Value>& args);

33 35

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4