Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mycard Mobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mycard Mobile
Commits
907f385e
Commit
907f385e
authored
Jun 20, 2018
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a7cede6c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
package.json
package.json
+1
-1
src/app/storage.service.ts
src/app/storage.service.ts
+9
-8
No files found.
package.json
View file @
907f385e
{
{
"name"
:
"mycard-mobile"
,
"name"
:
"mycard-mobile"
,
"version"
:
"1.0.3
2
"
,
"version"
:
"1.0.3
3
"
,
"license"
:
"UNLISENCED"
,
"license"
:
"UNLISENCED"
,
"scripts"
:
{
"scripts"
:
{
"ng"
:
"ng"
,
"ng"
:
"ng"
,
...
...
src/app/storage.service.ts
View file @
907f385e
import
{
EventEmitter
,
Injectable
}
from
'
@angular/core
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
*
as
path
from
'
path
'
;
import
*
as
path
from
'
path
'
;
import
*
as
webdav
from
'
webdav
'
;
import
*
as
webdav
from
'
webdav
'
;
import
{
LoginService
}
from
'
./login.service
'
;
import
{
LoginService
}
from
'
./login.service
'
;
import
{
BehaviorSubject
}
from
'
rxjs
'
;
interface
DirectoryStats
{
interface
DirectoryStats
{
filename
:
string
;
filename
:
string
;
...
@@ -27,7 +28,7 @@ export class StorageService {
...
@@ -27,7 +28,7 @@ export class StorageService {
app_id
=
'
ygopro
'
;
app_id
=
'
ygopro
'
;
client
=
webdav
(
'
https://api.mycard.moe/storage/
'
,
this
.
login
.
user
.
username
,
this
.
login
.
user
.
external_id
.
toString
());
client
=
webdav
(
'
https://api.mycard.moe/storage/
'
,
this
.
login
.
user
.
username
,
this
.
login
.
user
.
external_id
.
toString
());
working
=
new
EventEmitter
(
);
working
=
new
BehaviorSubject
(
false
);
constructor
(
private
login
:
LoginService
)
{}
constructor
(
private
login
:
LoginService
)
{}
...
@@ -111,11 +112,11 @@ export class StorageService {
...
@@ -111,11 +112,11 @@ export class StorageService {
// fixme: 如果远端和本地同时没有,但是 localStorage 里有,要删除
// fixme: 如果远端和本地同时没有,但是 localStorage 里有,要删除
// console.log('sync', 'done');
// console.log('sync', 'done');
this
.
working
.
emi
t
(
false
);
this
.
working
.
nex
t
(
false
);
}
}
async
download
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
,
time
:
number
)
{
async
download
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
,
time
:
number
)
{
this
.
working
.
emi
t
(
true
);
this
.
working
.
nex
t
(
true
);
// console.log('download', local_path, remote_path, index_path, time);
// console.log('download', local_path, remote_path, index_path, time);
const
data
:
ArrayBuffer
=
await
this
.
client
.
getFileContents
(
remote_path
);
const
data
:
ArrayBuffer
=
await
this
.
client
.
getFileContents
(
remote_path
);
window
.
ygopro
.
writeFile
(
local_path
,
Buffer
.
from
(
data
).
toString
(
'
base64
'
));
window
.
ygopro
.
writeFile
(
local_path
,
Buffer
.
from
(
data
).
toString
(
'
base64
'
));
...
@@ -125,7 +126,7 @@ export class StorageService {
...
@@ -125,7 +126,7 @@ export class StorageService {
}
}
async
upload
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
)
{
async
upload
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
)
{
this
.
working
.
emi
t
(
true
);
this
.
working
.
nex
t
(
true
);
// console.log('upload', local_path, remote_path, index_path);
// console.log('upload', local_path, remote_path, index_path);
const
data
=
this
.
read_local
(
local_path
);
const
data
=
this
.
read_local
(
local_path
);
await
this
.
client
.
putFileContents
(
remote_path
,
data
);
await
this
.
client
.
putFileContents
(
remote_path
,
data
);
...
@@ -141,13 +142,13 @@ export class StorageService {
...
@@ -141,13 +142,13 @@ export class StorageService {
}
}
remove_local
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
)
{
remove_local
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
)
{
this
.
working
.
emi
t
(
true
);
this
.
working
.
nex
t
(
true
);
window
.
ygopro
.
unlink
(
local_path
);
window
.
ygopro
.
unlink
(
local_path
);
localStorage
.
removeItem
(
index_path
);
localStorage
.
removeItem
(
index_path
);
}
}
async
remove_remote
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
)
{
async
remove_remote
(
local_path
:
string
,
remote_path
:
string
,
index_path
:
string
)
{
this
.
working
.
emi
t
(
true
);
this
.
working
.
nex
t
(
true
);
await
this
.
client
.
deleteFile
(
remote_path
);
await
this
.
client
.
deleteFile
(
remote_path
);
localStorage
.
removeItem
(
index_path
);
localStorage
.
removeItem
(
index_path
);
}
}
...
@@ -157,7 +158,7 @@ export class StorageService {
...
@@ -157,7 +158,7 @@ export class StorageService {
const
remote_path
=
path
.
join
(
root
,
local_path
);
const
remote_path
=
path
.
join
(
root
,
local_path
);
const
index_path
=
'
_FILE_
'
+
remote_path
;
const
index_path
=
'
_FILE_
'
+
remote_path
;
this
.
working
.
emi
t
(
true
);
this
.
working
.
nex
t
(
true
);
window
.
ygopro
.
unlink
(
local_path
);
window
.
ygopro
.
unlink
(
local_path
);
await
this
.
client
.
deleteFile
(
remote_path
);
await
this
.
client
.
deleteFile
(
remote_path
);
localStorage
.
removeItem
(
index_path
);
localStorage
.
removeItem
(
index_path
);
...
...
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