Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
5ba2e3f6
Commit
5ba2e3f6
authored
Jul 16, 2021
by
lianahus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checking for isFile
parent
942ab6f9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
7 deletions
+43
-7
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+18
-2
fileProvider.js
apps/remix-ide/src/app/files/fileProvider.js
+3
-0
remixDProvider.js
apps/remix-ide/src/app/files/remixDProvider.js
+2
-2
tab-proxy.js
apps/remix-ide/src/app/panels/tab-proxy.js
+2
-1
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+1
-1
remixdClient.ts
libs/remixd/src/services/remixdClient.ts
+17
-1
No files found.
apps/remix-ide/src/app/files/fileManager.js
View file @
5ba2e3f6
...
...
@@ -155,9 +155,9 @@ class FileManager extends Plugin {
* @param {string} path path of the directory
* @returns {boolean} true if path is a directory.
*/
isDirectory
(
path
)
{
async
isDirectory
(
path
)
{
const
provider
=
this
.
fileProviderOf
(
path
)
const
result
=
provider
.
isDirectory
(
path
)
const
result
=
await
provider
.
isDirectory
(
path
)
return
result
}
...
...
@@ -360,9 +360,11 @@ class FileManager extends Plugin {
async
remove
(
path
)
{
try
{
path
=
this
.
limitPluginScope
(
path
)
console
.
log
(
'remove fileManager,js '
,
path
)
await
this
.
_handleExists
(
path
,
`Cannot remove file or directory
${
path
}
`
)
const
provider
=
this
.
fileProviderOf
(
path
)
// this.emit('folderRemoved', path)
return
await
provider
.
remove
(
path
)
}
catch
(
e
)
{
throw
new
Error
(
e
)
...
...
@@ -383,6 +385,7 @@ class FileManager extends Plugin {
this
.
_deps
.
browserExplorer
.
event
.
on
(
'fileRemoved'
,
(
path
)
=>
{
this
.
fileRemovedEvent
(
path
)
})
this
.
_deps
.
browserExplorer
.
event
.
on
(
'fileAdded'
,
(
path
)
=>
{
this
.
fileAddedEvent
(
path
)
})
this
.
_deps
.
localhostExplorer
.
event
.
on
(
'fileRemoved'
,
(
path
)
=>
{
this
.
fileRemovedEvent
(
path
)
})
this
.
_deps
.
localhostExplorer
.
event
.
on
(
'folderRemoved'
,
(
path
)
=>
{
this
.
removeTabsOfPath
(
path
)
})
this
.
_deps
.
localhostExplorer
.
event
.
on
(
'errored'
,
(
event
)
=>
{
this
.
removeTabsOf
(
this
.
_deps
.
localhostExplorer
)
})
this
.
_deps
.
localhostExplorer
.
event
.
on
(
'closed'
,
(
event
)
=>
{
this
.
removeTabsOf
(
this
.
_deps
.
localhostExplorer
)
})
this
.
_deps
.
workspaceExplorer
.
event
.
on
(
'fileChanged'
,
(
path
)
=>
{
this
.
fileChangedEvent
(
path
)
})
...
...
@@ -547,6 +550,19 @@ class FileManager extends Plugin {
}
}
removeTabsOfPath
(
path
)
{
for
(
const
tab
in
this
.
openedFiles
)
{
if
(
tab
.
substring
(
0
,
path
.
length
)
===
path
)
{
console
.
log
(
'removeTabsOfPath '
,
path
)
if
(
path
===
this
.
_deps
.
config
.
get
(
'currentFile'
))
{
this
.
_deps
.
config
.
set
(
'currentFile'
,
''
)
}
this
.
editor
.
discard
(
path
)
delete
this
.
openedFiles
[
path
]
}
}
}
fileRemovedEvent
(
path
)
{
if
(
path
===
this
.
_deps
.
config
.
get
(
'currentFile'
))
{
this
.
_deps
.
config
.
set
(
'currentFile'
,
''
)
...
...
apps/remix-ide/src/app/files/fileProvider.js
View file @
5ba2e3f6
...
...
@@ -185,6 +185,7 @@ class FileProvider {
window
.
remixFileSystem
.
rmdirSync
(
path
,
console
.
log
)
}
this
.
event
.
emit
(
'fileRemoved'
,
this
.
_normalizePath
(
path
))
console
.
log
(
'file provider remove remove '
,
path
)
}
}
catch
(
e
)
{
console
.
log
(
e
)
...
...
@@ -250,6 +251,8 @@ class FileProvider {
if
(
window
.
remixFileSystem
.
existsSync
(
path
)
&&
!
window
.
remixFileSystem
.
statSync
(
path
).
isDirectory
())
{
window
.
remixFileSystem
.
unlinkSync
(
path
,
console
.
log
)
this
.
event
.
emit
(
'fileRemoved'
,
this
.
_normalizePath
(
path
))
console
.
log
(
'file provider removefile remove '
,
path
)
return
true
}
else
return
false
}
...
...
apps/remix-ide/src/app/files/remixDProvider.js
View file @
5ba2e3f6
...
...
@@ -35,10 +35,11 @@ module.exports = class RemixDProvider extends FileProvider {
this
.
_appManager
.
on
(
'remixd'
,
'fileRemoved'
,
(
path
)
=>
{
this
.
event
.
emit
(
'fileRemoved'
,
path
)
console
.
log
(
'remixd appmanager listener remove '
,
path
)
})
this
.
_appManager
.
on
(
'remixd'
,
'fileRenamed'
,
(
oldPath
,
newPath
)
=>
{
this
.
event
.
emit
(
'fileRe
mov
ed'
,
oldPath
,
newPath
)
this
.
event
.
emit
(
'fileRe
nam
ed'
,
oldPath
,
newPath
)
})
this
.
_appManager
.
on
(
'remixd'
,
'rootFolderChanged'
,
()
=>
{
...
...
@@ -141,7 +142,6 @@ module.exports = class RemixDProvider extends FileProvider {
this
.
_appManager
.
call
(
'remixd'
,
'remove'
,
{
path
:
unprefixedpath
})
.
then
(
result
=>
{
const
path
=
unprefixedpath
delete
this
.
filesContent
[
path
]
resolve
(
true
)
this
.
init
()
...
...
apps/remix-ide/src/app/panels/tab-proxy.js
View file @
5ba2e3f6
...
...
@@ -44,7 +44,8 @@ export class TabProxy extends Plugin {
fileManager
.
events
.
on
(
'fileRemoved'
,
(
name
)
=>
{
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
console
.
log
(
'wotk= '
,
workspace
)
console
.
log
(
'mode= '
,
this
.
fileManager
.
mode
)
workspace
?
this
.
removeTab
(
workspace
+
'/'
+
name
)
:
this
.
removeTab
(
this
.
fileManager
.
mode
+
'/'
+
name
)
})
...
...
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
5ba2e3f6
...
...
@@ -408,7 +408,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
try
{
await
fileManager
.
remove
(
p
)
}
catch
(
e
)
{
const
isDir
=
state
.
fileManager
.
isDirectory
(
p
)
const
isDir
=
await
state
.
fileManager
.
isDirectory
(
p
)
toast
(
`Failed to remove
${
isDir
?
'folder'
:
'file'
}
${
p
}
.`
)
}
}
...
...
libs/remixd/src/services/remixdClient.ts
View file @
5ba2e3f6
...
...
@@ -180,12 +180,19 @@ export class RemixdClient extends PluginClient {
if
(
!
fs
.
existsSync
(
path
))
return
reject
(
new
Error
(
'File not found '
+
path
))
if
(
!
isRealPath
(
path
))
return
if
(
this
.
_isFile
(
path
))
{
this
.
emit
(
'fileRemoved'
,
path
)
console
.
log
(
'isfile '
,
path
)
}
else
{
this
.
emit
(
'folderRemoved'
,
path
)
console
.
log
(
'isFolder '
,
path
)
}
return
fs
.
remove
(
path
,
(
error
:
Error
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
return
reject
(
new
Error
(
'Failed to remove file/directory: '
+
error
))
}
this
.
emit
(
'fileRemoved'
,
args
.
path
)
resolve
(
true
)
})
})
...
...
@@ -194,6 +201,15 @@ export class RemixdClient extends PluginClient {
}
}
_isFile
(
path
:
string
):
boolean
{
try
{
console
.
log
(
'isfile inside '
,
path
)
return
fs
.
statSync
(
path
).
isFile
()
}
catch
(
error
)
{
throw
new
Error
(
error
)
}
}
isDirectory
(
args
:
SharedFolderArgs
):
boolean
{
try
{
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
...
...
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