Skip to content

Commit

Permalink
removed startListeningToDirectory and url extension
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiTheRedNinja committed Jul 16, 2022
1 parent 93bf25c commit 33dc193
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions CodeEditModules/Modules/WorkspaceClient/src/Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,12 @@ public extension WorkspaceClient {
anotherInstanceRan = !(somethingChanged ?? false) ? 0 : anotherInstanceRan - 1
}
subject.send(workspaceItem.children ?? [])
startListeningToDirectory()
isRunning = false
anotherInstanceRan = 0
// reload data in outline view controller through the main thread
DispatchQueue.main.async { onRefresh() }
}

// no longer functional. Directory listening code has been moved to the FileItem.
func startListeningToDirectory() {}

func stopListeningToDirectory(directory: URL? = nil) {
if directory != nil {
flattenedFileItems[directory!.relativePath]?.watcher?.cancel()
Expand All @@ -164,9 +160,7 @@ public extension WorkspaceClient {
return Self(
folderURL: { folderURL },
getFiles: subject
.handleEvents(receiveSubscription: { _ in
startListeningToDirectory()
}, receiveCancel: {
.handleEvents(receiveCancel: {
stopListeningToDirectory()
})
.receive(on: RunLoop.main)
Expand All @@ -180,26 +174,3 @@ public extension WorkspaceClient {
)
}
}

extension URL {
var attributes: [FileAttributeKey: Any]? {
do {
return try FileManager.default.attributesOfItem(atPath: path)
} catch let error as NSError {
print("FileAttribute error: \(error)")
}
return nil
}

var fileSize: UInt64 {
return attributes?[.size] as? UInt64 ?? UInt64(0)
}

var fileSizeString: String {
return ByteCountFormatter.string(fromByteCount: Int64(fileSize), countStyle: .file)
}

var creationDate: Date? {
return attributes?[.creationDate] as? Date
}
}

0 comments on commit 33dc193

Please sign in to comment.