Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Guillaume Royer
jio
Commits
fcaa08e6
Commit
fcaa08e6
authored
Jan 03, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indexstorage.js updates unmodified db fixed
parent
37de729a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
3 deletions
+32
-3
src/jio.storage/indexstorage.js
src/jio.storage/indexstorage.js
+32
-3
No files found.
src/jio.storage/indexstorage.js
View file @
fcaa08e6
...
@@ -197,6 +197,24 @@
...
@@ -197,6 +197,24 @@
*/
*/
that
.
_database
=
spec
.
database
||
[];
that
.
_database
=
spec
.
database
||
[];
/**
* True if it has been modified
*
* @property modified
* @type Boolean
* @default false
*/
that
.
modified
=
false
;
/**
* Updates the modified date
*
* @method touch
*/
that
.
touch
=
function
()
{
that
.
modified
=
true
;
};
/**
/**
* Adds a metadata object in the database, replace if already exist
* Adds a metadata object in the database, replace if already exist
*
*
...
@@ -232,10 +250,11 @@
...
@@ -232,10 +250,11 @@
that
.
_database
.
push
(
needed_meta
);
that
.
_database
.
push
(
needed_meta
);
that
.
_location
[
meta
.
_id
]
=
that
.
_database
.
length
-
1
;
that
.
_location
[
meta
.
_id
]
=
that
.
_database
.
length
-
1
;
}
}
that
.
modified
=
true
;
return
true
;
return
true
;
}
}
if
(
typeof
that
.
_location
[
meta
.
_id
]
===
"
number
"
)
{
if
(
typeof
that
.
_location
[
meta
.
_id
]
===
"
number
"
)
{
that
.
remove
(
meta
);
return
that
.
remove
(
meta
);
}
}
return
false
;
return
false
;
};
};
...
@@ -245,6 +264,7 @@
...
@@ -245,6 +264,7 @@
*
*
* @method remove
* @method remove
* @param {Object} meta The metadata to remove
* @param {Object} meta The metadata to remove
* @return {Boolean} true if removed else false
*/
*/
that
.
remove
=
function
(
meta
)
{
that
.
remove
=
function
(
meta
)
{
if
(
typeof
meta
.
_id
!==
"
string
"
)
{
if
(
typeof
meta
.
_id
!==
"
string
"
)
{
...
@@ -252,11 +272,13 @@
...
@@ -252,11 +272,13 @@
}
}
if
(
typeof
that
.
_location
[
meta
.
_id
]
!==
"
number
"
)
{
if
(
typeof
that
.
_location
[
meta
.
_id
]
!==
"
number
"
)
{
// throw new ReferenceError("Not Found");
// throw new ReferenceError("Not Found");
return
;
return
false
;
}
}
that
.
_database
[
that
.
_location
[
meta
.
_id
]]
=
null
;
that
.
_database
[
that
.
_location
[
meta
.
_id
]]
=
null
;
that
.
_free
.
push
(
that
.
_location
[
meta
.
_id
]);
that
.
_free
.
push
(
that
.
_location
[
meta
.
_id
]);
delete
that
.
_location
[
meta
.
_id
];
delete
that
.
_location
[
meta
.
_id
];
that
.
modified
=
true
;
return
true
;
};
};
/**
/**
...
@@ -354,6 +376,8 @@
...
@@ -354,6 +376,8 @@
that
.
_database
.
splice
(
i
,
1
);
that
.
_database
.
splice
(
i
,
1
);
}
}
}
}
that
.
modified
=
true
;
return
true
;
};
};
/**
/**
...
@@ -454,11 +478,13 @@
...
@@ -454,11 +478,13 @@
IndexStorage
.
prototype
.
getIndexDatabase
=
function
(
command
,
index
)
{
IndexStorage
.
prototype
.
getIndexDatabase
=
function
(
command
,
index
)
{
index
=
this
.
_indices
[
index
];
index
=
this
.
_indices
[
index
];
function
makeNewIndex
()
{
function
makeNewIndex
()
{
return
new
JSONIndex
({
var
json_index
=
new
JSONIndex
({
"
_id
"
:
index
.
id
,
"
_id
"
:
index
.
id
,
"
_attachment
"
:
index
.
attachment
||
"
body
"
,
"
_attachment
"
:
index
.
attachment
||
"
body
"
,
"
indexing
"
:
index
.
index
"
indexing
"
:
index
.
index
});
});
json_index
.
touch
();
return
json_index
;
}
}
return
command
.
storage
(
return
command
.
storage
(
index
.
sub_storage
||
this
.
_sub_storage
index
.
sub_storage
||
this
.
_sub_storage
...
@@ -497,6 +523,9 @@
...
@@ -497,6 +523,9 @@
IndexStorage
.
prototype
.
storeIndexDatabase
=
function
(
command
,
database
,
IndexStorage
.
prototype
.
storeIndexDatabase
=
function
(
command
,
database
,
index
)
{
index
)
{
var
that
=
this
;
var
that
=
this
;
if
(
!
database
.
modified
)
{
return
RSVP
.
resolve
({
"
result
"
:
"
success
"
});
}
index
=
this
.
_indices
[
index
];
index
=
this
.
_indices
[
index
];
function
putAttachment
()
{
function
putAttachment
()
{
return
command
.
storage
(
return
command
.
storage
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment