Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
342
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
28
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
0f67a544
Commit
0f67a544
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
#1414
parent
e69554f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/models/drive-file.ts
+3
-3
3 additions, 3 deletions
src/models/drive-file.ts
src/services/drive/add-file.ts
+30
-3
30 additions, 3 deletions
src/services/drive/add-file.ts
with
33 additions
and
6 deletions
src/models/drive-file.ts
+
3
−
3
View file @
0f67a544
...
...
@@ -8,11 +8,11 @@ import MessagingMessage, { deleteMessagingMessage } from './messaging-message';
import
User
from
'
./user
'
;
const
DriveFile
=
monkDb
.
get
<
IDriveFile
>
(
'
driveFiles.files
'
);
DriveFile
.
createIndex
(
'
metadata.uri
'
,
{
sparse
:
true
,
unique
:
true
});
export
default
DriveFile
;
export
const
DriveFileChunk
=
monkDb
.
get
(
'
driveFiles.chunks
'
);
const
getGridFSBucket
=
async
():
Promise
<
mongo
.
GridFSBucket
>
=>
{
const
db
=
await
nativeDbConn
();
const
bucket
=
new
mongo
.
GridFSBucket
(
db
,
{
...
...
@@ -93,7 +93,7 @@ export async function deleteDriveFile(driveFile: string | mongo.ObjectID | IDriv
}
// このDriveFileのチャンクをすべて削除
await
monkDb
.
get
(
'
d
riveFile
s.c
hunk
s
'
)
.
remove
({
await
D
riveFile
C
hunk
.
remove
({
files_id
:
d
.
_id
});
...
...
This diff is collapsed.
Click to expand it.
src/services/drive/add-file.ts
+
30
−
3
View file @
0f67a544
...
...
@@ -10,12 +10,12 @@ import * as debug from 'debug';
import
fileType
=
require
(
'
file-type
'
);
import
prominence
=
require
(
'
prominence
'
);
import
DriveFile
,
{
IMetadata
,
getGridFSBucket
,
IDriveFile
}
from
'
../../models/drive-file
'
;
import
DriveFile
,
{
IMetadata
,
getGridFSBucket
,
IDriveFile
,
DriveFileChunk
}
from
'
../../models/drive-file
'
;
import
DriveFolder
from
'
../../models/drive-folder
'
;
import
{
pack
}
from
'
../../models/drive-file
'
;
import
event
,
{
publishDriveStream
}
from
'
../../publishers/stream
'
;
import
getAcct
from
'
../../acct/render
'
;
import
{
IUser
}
from
'
../../models/user
'
;
import
{
IUser
,
isLocalUser
}
from
'
../../models/user
'
;
const
gm
=
_gm
.
subClass
({
imageMagick
:
true
...
...
@@ -207,7 +207,34 @@ const addFile = async (
// If usage limit exceeded
if
(
usage
+
size
>
user
.
driveCapacity
)
{
throw
'
no-free-space
'
;
if
(
isLocalUser
(
user
))
{
throw
'
no-free-space
'
;
}
else
{
//#region (アバターまたはバナーを含まず)最も古いファイルを削除する
const
oldFile
=
await
DriveFile
.
findOne
({
_id
:
{
$nin
:
[
user
.
avatarId
,
user
.
bannerId
]
}
},
{
sort
:
{
_id
:
1
}
});
if
(
oldFile
)
{
// チャンクをすべて削除
DriveFileChunk
.
remove
({
files_id
:
oldFile
.
_id
});
DriveFile
.
update
({
_id
:
oldFile
.
_id
},
{
$set
:
{
'
metadata.deletedAt
'
:
new
Date
()
}
});
}
//#endregion
}
}
})()
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment