Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
d7cfe31
feat(go.mod): change package name for the project
zgs225 Aug 11, 2022
240a676
feat: add new-ui
zgs225 Aug 15, 2022
9341fba
feat: new-ui integrates i18nnext
zgs225 Aug 16, 2022
0dbfe0f
:sparkles: initialize project
zgs225 Aug 22, 2022
b959661
:sparkles: (i18n): integrate react-i18next
zgs225 Aug 23, 2022
de7c4d8
:sparkles: page(login): add login form
zgs225 Aug 24, 2022
63ea838
:children_crossing: feat(login): improve page style
zgs225 Aug 24, 2022
8078c33
feat(login): complete login page
zgs225 Aug 31, 2022
b60f058
chroe(build): remove husky hook files to fix commit issue in windows
zgs225 Aug 31, 2022
977ea6b
feat(site): add dynamic title
zgs225 Aug 31, 2022
2680f92
feat(pages): add 404 page
zgs225 Aug 31, 2022
ecb7495
feat(navbar): add global navbar component for PC view
zgs225 Sep 2, 2022
a7e4ea4
feat(navbar): add global navbar component for mobile phone view
zgs225 Sep 2, 2022
2945523
feat(navbar): add global navbar component for mobile phone view
zgs225 Sep 2, 2022
265c005
feat(documents): completes upload page
zgs225 Sep 6, 2022
e5ea715
feat(documents): completes upload page
zgs225 Sep 6, 2022
1cd74b3
feat(documents): add file tree view
zgs225 Sep 7, 2022
356e901
feat(ui): make react app wrapper to handle images
zgs225 Sep 7, 2022
b4c45e6
chore(ui): set theme color for browser
zgs225 Sep 7, 2022
2363d8e
fix(ui): prevent icon shrink in file tree view
zgs225 Sep 7, 2022
c0e6b59
fix(ui): page height at desktop screen
zgs225 Sep 7, 2022
8336b83
Merge pull request #1 from ddvk/master
zgs225 Sep 7, 2022
1d6c1e6
feat(ui): support file type icon in file tree file
zgs225 Sep 7, 2022
dfbde45
chore(ui): replace some icons
zgs225 Sep 7, 2022
c75b13d
chore(ui): replace some icons
zgs225 Sep 8, 2022
3a03e5b
feat(ui): add logout
zgs225 Sep 8, 2022
37a6ecc
feat(ui): add reset password page
zgs225 Sep 8, 2022
2ce559b
chore(ui): remove useless classes
zgs225 Sep 8, 2022
6c1ddc6
feat(ui): add devices page
zgs225 Sep 9, 2022
efd55d7
feat(ui): add devices page
zgs225 Sep 9, 2022
3532245
chore(upload): remove save extension to raw metadata
zgs225 Sep 9, 2022
d6db39b
chore(upload): increase max upload size
zgs225 Sep 9, 2022
2404ba5
refactor(go.mod): rename go mod name
zgs225 Sep 9, 2022
9851f93
chore(project): revert useless commits
zgs225 Sep 9, 2022
51bf0d7
feat(documents): add delete document
zgs225 Sep 14, 2022
8837473
chore(ui): improve FileMenu style
zgs225 Sep 14, 2022
e2d6d53
feat(documents): add rename api
zgs225 Sep 14, 2022
6ced665
feat(documents): add rename api
zgs225 Sep 14, 2022
c237256
feat(ui): add rename document
zgs225 Sep 15, 2022
6df10cd
feat(dockerfile): use alpine as base image
zgs225 Sep 15, 2022
bcc2811
fix(ui): remove background color when tap on touchscreen
zgs225 Sep 15, 2022
1b5f9f5
chore(ui): adjust dialog
zgs225 Sep 15, 2022
c775d13
fix(ui): menu bar position error when dialog showup
zgs225 Sep 15, 2022
cab0919
fix(ui): menu bar position error when dialog showup
zgs225 Sep 15, 2022
b53b159
chore(ui): improve animation
zgs225 Sep 16, 2022
efd4e79
feat(ui): add export document as pdf
zgs225 Sep 16, 2022
5e760bc
feat(documents): add viewer to preview pdf document
zgs225 Sep 17, 2022
c08cb71
feat(documents): lazy load pdf pages
zgs225 Sep 17, 2022
7fb2977
chore(ui): rewrite document export
zgs225 Sep 18, 2022
00dcb61
chore(ui): style file tree divid line
zgs225 Sep 18, 2022
6bd7c01
feat(ui): reload docs after files uploaded
zgs225 Sep 18, 2022
d8e0f0b
feat(ui): add empty document tip
zgs225 Sep 18, 2022
a67a81d
feat(ui): add empty document tip
zgs225 Sep 19, 2022
1620e59
performance(ui): improve pdf viewer performance
zgs225 Sep 19, 2022
a1bcfa7
performance(ui): improve pdf viewer performance
zgs225 Sep 19, 2022
51ea518
fix(ui): scale of pdf viewer
zgs225 Sep 19, 2022
cc0a9a1
feat(ui): add favicons
zgs225 Sep 19, 2022
6c29277
feat(api): add create folder api for react app
zgs225 Sep 20, 2022
2d0199b
refactor(ui): rearrange codes of FileTreeView
zgs225 Sep 20, 2022
8baf686
feat(ui): add create folder
zgs225 Sep 20, 2022
3872ea4
chore(ui): hide create folder button when in a folder already
zgs225 Sep 20, 2022
04cfefe
feat(ui): add create folder
zgs225 Sep 20, 2022
7241ee9
feat(ui): add move documents
zgs225 Sep 22, 2022
3531a5f
chore(api): remove some logs
zgs225 Sep 22, 2022
4780475
fix(ui): fix move documents container can not scroll issue
zgs225 Sep 22, 2022
1cd1318
fix(ui): load new creation folders when moving documents
zgs225 Sep 22, 2022
f42dbe0
chore(ui): improve animation
zgs225 Sep 22, 2022
8dfd84f
chore(ui): fix z-index bug
zgs225 Sep 22, 2022
9d0007b
fix(ui): fix z-index bug
zgs225 Sep 22, 2022
65efb1a
chore(ui): remove trivial file
zgs225 Sep 22, 2022
34cc3c6
chore(ui): add hover style for file tree view
zgs225 Sep 22, 2022
0c3118b
chore(ui): add hover style for file tree view
zgs225 Sep 22, 2022
d3985ea
feat(ui): add rename folder
zgs225 Sep 23, 2022
7fc1c0f
chore(ui): UI imporvement
zgs225 Sep 23, 2022
16aa0fa
chore(ui): UI imporvement
zgs225 Sep 23, 2022
1e9beae
feat(ui): add remove folder
zgs225 Sep 23, 2022
fbdb3ba
fix(ui): dismiss context menu when touchscreen scroll
zgs225 Sep 23, 2022
26866af
chore(ui): toast error message when remove non-empty folder
zgs225 Sep 23, 2022
faaf64d
chore(ui): toast error message when remove non-empty folder
zgs225 Sep 23, 2022
51ed6e0
fix(ui): file element flash
zgs225 Sep 23, 2022
c7577ca
feat(ui): add nested folders
zgs225 Sep 23, 2022
f95b721
feat(ui): add nested folders while moving documents
zgs225 Sep 23, 2022
cb72aa1
chore(ui): to some improvements
zgs225 Sep 23, 2022
6fd80bf
fix(ui): notification message error
zgs225 Sep 23, 2022
5665823
fix(ui): dir element dispeared after discard rename form
zgs225 Sep 24, 2022
2e712ed
feat(ui): add users management pages
zgs225 Sep 29, 2022
ee79b8e
fix(build): type checked error
zgs225 Sep 29, 2022
9d17bdf
chore(api): set first page as cover when create document
zgs225 Sep 29, 2022
ce4bf25
style(ui): set file tree min height
zgs225 Sep 30, 2022
5424687
style(ui): set context menu not wrap
zgs225 Sep 30, 2022
e8b5462
style(ui): set context menu not wrap
zgs225 Sep 30, 2022
fb6cc46
style(ui): add folder enter/exit animation
zgs225 Sep 30, 2022
e3ef5bd
style(ui): optimize FileMenu style
zgs225 Sep 30, 2022
30c5867
style(ui): optimize FileMenu style
zgs225 Sep 30, 2022
7e82e2a
style(ui): fix sticky not works
zgs225 Sep 30, 2022
1e5b81f
style(ui): fix sticky not works
zgs225 Sep 30, 2022
b4d9230
style(ui): set z index for sticky component
zgs225 Sep 30, 2022
0cbac8e
style(ui): set padding right when model appears only on windows
zgs225 Sep 30, 2022
a942920
style(ui): change name and logo
zgs225 Oct 10, 2022
eb4c7ce
style(ui): change name and logo
zgs225 Oct 10, 2022
8705fba
chore: remove trivial file
zgs225 Oct 14, 2022
9b4cfd8
feat(api): implements create folder API for sync15 backend
zgs225 Oct 26, 2022
143d198
fix(api): use metadata hash as content hash
zgs225 Oct 27, 2022
d5fc734
build: remove git commit hooks
zgs225 Oct 27, 2022
ba1de1a
chore: remove npm lock file
zgs225 Oct 27, 2022
0077603
feat(api): implements rename/move API for sync15 backend
zgs225 Oct 27, 2022
ce1a4d9
feat(api+ui): add remove document API for sync15 backend and add serv…
zgs225 Oct 28, 2022
abb519f
feat(api): set parent id to trash when removing document
zgs225 Oct 28, 2022
f3becba
feat(api): distinguish file type at file tree for sync15 backend
zgs225 Oct 28, 2022
bb816ee
build: fix make build and make all
zgs225 Oct 29, 2022
925006f
feat: increment max upload size
zgs225 Mar 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ dist/
node_modules/
assets_vfsdata.go
.vscode/
.idea/
assets_vfsdata.go
__debug_bin
# Dependency directories (remove the comment below to include it)
# vendor/

Expand Down
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
ARG VERSION=0.0.0
FROM --platform=$BUILDPLATFORM node:lts-alpine as uibuilder
FROM --platform=$BUILDPLATFORM node:lts as uibuilder
WORKDIR /src
COPY ui .
COPY new-ui .
RUN yarn && yarn build

FROM golang:1-alpine as gobuilder
ARG VERSION
WORKDIR /src
COPY . .
COPY --from=uibuilder /src/build ./ui/build
RUN apk add git
COPY . .
COPY --from=uibuilder /src/dist ./new-ui/dist
RUN go generate ./... && CGO_ENABLED=0 go build -ldflags "-s -w -X main.version=${VERSION}" -o rmfakecloud-docker ./cmd/rmfakecloud/

FROM scratch
FROM alpine
EXPOSE 3000
RUN --mount=from=busybox:latest,src=/bin/,dst=/bin/ mkdir -m 1755 /tmp
COPY --from=gobuilder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=gobuilder /src/rmfakecloud-docker /
ENTRYPOINT ["/rmfakecloud-docker"]
CMD ["/rmfakecloud-docker"]
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ OUT_DIR := dist
CMD := ./cmd/rmfakecloud
BINARY := rmfakecloud
BUILD = go build -ldflags $(LDFLAGS) -o $(@) $(CMD)
ASSETS = ui/build
ASSETS = new-ui/dist
GOFILES := $(shell find . -iname '*.go' ! -iname "*_test.go")
GOFILES += $(ASSETS)
UIFILES := $(shell find ui/src)
UIFILES += $(shell find ui/public)
UIFILES += ui/package.json
UIFILES := $(shell find new-ui/src)
UIFILES += $(shell find new-ui/public)
UIFILES += $(shell find new-ui/types)
UIFILES += new-ui/package.json
TARGETS := $(addprefix $(OUT_DIR)/$(BINARY)-, x64 armv6 armv7 arm64 win64 docker)
YARN = yarn --cwd ui
YARN = yarn --cwd new-ui

.PHONY: all run runui clean test testgo testui

Expand Down Expand Up @@ -43,21 +44,18 @@ container: $(OUT_DIR)/$(BINARY)-docker
run: $(ASSETS)
go run $(CMD) $(ARG)

$(ASSETS): $(UIFILES) ui/yarn.lock
@cp ui/node_modules/pdfjs-dist/build/pdf.worker.js ui/public/
$(ASSETS): $(UIFILES) new-ui/yarn.lock
$(YARN) build
@#remove unneeded stuff, todo: eject
@rm ui/build/service-worker.js ui/build/precache-manifest* ui/build/asset-manifest.json 2> /dev/null || true

ui/yarn.lock: ui/node_modules ui/package.json
new-ui/yarn.lock: new-ui/node_modules new-ui/package.json
$(YARN)
@touch -mr $(shell ls -Atd $? | head -1) $@

ui/node_modules:
new-ui/node_modules:
mkdir -p $@

runui: ui/yarn.lock
$(YARN) start
runui: new-ui/yarn.lock
$(YARN) dev

clean:
rm -f $(OUT_DIR)/*
Expand Down
3 changes: 2 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ func NewApp(cfg *config.Config) App {
Cfg: cfg,
},
}
uiApp := ui.New(cfg, fsStorage, codeConnector, ntfHub, fsStorage, fsStorage)

uiApp := ui.New(cfg, fsStorage, codeConnector, ntfHub, fsStorage, fsStorage, fsStorage)

storageapp := fs.NewApp(cfg, fsStorage)

Expand Down
3 changes: 3 additions & 0 deletions internal/messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ type RawMetadata struct {
CurrentPage int `json:"CurrentPage"`
Bookmarked bool `json:"Bookmarked"`
Parent string `json:"Parent"`

// For distinguish file type at file tree, don't dump to disk
Extension string `json:"-"`
}

// IDRequest request with only an id
Expand Down
124 changes: 124 additions & 0 deletions internal/storage/fs/blob_folder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package fs

import (
"errors"
"strconv"
"strings"
"time"

"github.com/ddvk/rmfakecloud/internal/storage"
"github.com/ddvk/rmfakecloud/internal/storage/models"
"github.com/google/uuid"
)

// CreateBlobFolder create a sync15 folder
func (fs *FileSystemStorage) CreateBlobFolder(uid, name, parent string) (*storage.Document, error) {
name = strings.TrimSpace(name)
parent = strings.TrimSpace(parent)

tree, err := fs.GetTree(uid)

if err != nil {
return nil, err
}

// Check parent
if len(parent) != 0 {
parentDoc, err := tree.FindDoc(parent)

if err != nil {
return nil, err
}

if parentDoc.MetadataFile.CollectionType != models.CollectionType {
return nil, errors.New("Parent is not a folder")
}
}

docId := uuid.New().String()
blobPath := fs.getUserBlobPath(uid)

// Create metadata
metadata := models.MetadataFile{
DocumentName: name,
CollectionType: models.CollectionType,
Parent: parent,
Version: 1,
LastModified: strconv.FormatInt(time.Now().UnixMilli(), 10),
Synced: true,
MetadataModified: true,
}

mdHash, mdSize, err := createMetadataFile(metadata, blobPath)

if err != nil {
return nil, err
}

mdHashEntry := models.NewFileHashEntry(mdHash, docId+models.MetadataFileExt)
mdHashEntry.Size = mdSize

// New hash doc
hashDoc := models.NewHashDocMeta(docId, metadata)

if err = hashDoc.AddFile(mdHashEntry); err != nil {
return nil, err
}

// Create content
content := `{"tags":[]}`
contentHash, contentSize, err := models.Hash(strings.NewReader(content))
if err != nil {
return nil, err
}
if err = saveTo(strings.NewReader(content), contentHash, blobPath); err != nil {
return nil, err
}
contentHashEntry := models.NewFileHashEntry(contentHash, docId+models.ContentFileExt)
contentHashEntry.Size = contentSize
if err = hashDoc.AddFile(contentHashEntry); err != nil {
return nil, err
}

if err = tree.Add(hashDoc); err != nil {
return nil, err
}

hashDocIndexReader, err := hashDoc.IndexReader()
if err != nil {
return nil, err
}
if err = saveTo(hashDocIndexReader, hashDoc.Hash, blobPath); err != nil {
return nil, err
}

rootIndexReader, err := tree.RootIndex()
if err != nil {
return nil, err
}
if err = saveTo(rootIndexReader, tree.Hash, blobPath); err != nil {
return nil, err
}

blobStorage := &LocalBlobStorage{
fs: fs,
uid: uid,
}

gen, err := blobStorage.WriteRootIndex(tree.Generation, tree.Hash)
if err != nil {
return nil, err
}
tree.Generation = gen

if err = fs.SaveTree(uid, tree); err != nil {
return nil, err
}

return &storage.Document{
ID: docId,
Type: models.CollectionType,
Name: name,
Version: 1,
}, nil
}
106 changes: 106 additions & 0 deletions internal/storage/fs/blobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,112 @@ func (fs *FileSystemStorage) StoreBlob(uid, id string, stream io.Reader, lastGen
return
}

// GetBlobMetadata get metadata for a blob document
func (fs *FileSystemStorage) GetBlobMetadata(uid, docId string) (*models.MetadataFile, error) {
tree, err := fs.GetTree(uid)

if err != nil {
return nil, err
}

hashDoc, err := tree.FindDoc(docId)

if err != nil {
return nil, err
}

return &hashDoc.MetadataFile, nil
}

func (fs *FileSystemStorage) UpdateBlobMetadata(uid, docId string, md *models.MetadataFile) error {
tree, err := fs.GetTree(uid)

if err != nil {
return err
}

hashDoc, err := tree.FindDoc(docId)

if err != nil {
return err
}

md.MetadataModified = true
md.Synced = false
md.Version += 1
md.LastModified = strconv.FormatInt(time.Now().UnixMilli(), 10)

blobPath := fs.getUserBlobPath(uid)

// Recreate metadata file
mdHash, mdSize, err := createMetadataFile(*md, blobPath)

if err != nil {
return err
}

mdHashEntry := models.NewFileHashEntry(mdHash, docId+models.MetadataFileExt)
mdHashEntry.Size = mdSize

// New hash doc
newHashDoc := models.NewHashDocMeta(docId, *md)

if err = newHashDoc.AddFile(mdHashEntry); err != nil {
return err
}

// Copy entries from old hash doc except metadata
for _, entry := range hashDoc.Files {
if strings.HasSuffix(entry.EntryName, models.MetadataFileExt) {
continue
}
if err = newHashDoc.AddFile(entry); err != nil {
return err
}
}

if err = tree.Remove(docId); err != nil {
return err
}

if err = tree.Add(newHashDoc); err != nil {
return err
}

hashDocIndexReader, err := newHashDoc.IndexReader()
if err != nil {
return err
}
if err = saveTo(hashDocIndexReader, newHashDoc.Hash, blobPath); err != nil {
return err
}

rootIndexReader, err := tree.RootIndex()
if err != nil {
return err
}
if err = saveTo(rootIndexReader, tree.Hash, blobPath); err != nil {
return err
}

blobStorage := &LocalBlobStorage{
fs: fs,
uid: uid,
}

gen, err := blobStorage.WriteRootIndex(tree.Generation, tree.Hash)
if err != nil {
return err
}
tree.Generation = gen

if err = fs.SaveTree(uid, tree); err != nil {
return err
}

return nil
}

//use file size as generation
func generationFromFileSize(size int64) int64 {
//time + 1 space + 64 hash + 1 newline
Expand Down
1 change: 1 addition & 0 deletions internal/storage/fs/documentcreator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func createContent(fileType string) string {
`
{
"dummyDocument": false,
"coverPageNumber": 0,
"extraMetadata": {
"LastPen": "Finelinerv2",
"LastTool": "Finelinerv2",
Expand Down
Loading