Skip to content

Commit

Permalink
Revert "add delete fn"
Browse files Browse the repository at this point in the history
This reverts commit f790544.
  • Loading branch information
pivilartisant committed Aug 9, 2024
1 parent f790544 commit 83ba542
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 44 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ Ensure you have `task` installed. Follow the instructions [here](https://taskfil

DeWeb CLI is a command-line tool designed for deploying, editing, and deleting decentralized websites on the DeWeb platform.

## Table of Contents

- [Usage](#usage)
- [Commands](#commands)
- [upload](#upload)
- [edit](#edit)
- [view](#view)
- [delete](#delete)
- [Configuration](#configuration)
- [Logging](#logging)
- [License](#license)

## Usage

Once installed, you can use the `deweb-cli` command to interact with DeWeb. Below is the basic usage syntax:
Expand Down Expand Up @@ -156,7 +144,3 @@ sc_config:
## Logging
The CLI logs its output to `./deweb-cli.log`. Logging is initialized automatically when the application starts.

## License

DeWeb CLI is licensed under the MIT License. See the `LICENSE` file for more information.
24 changes: 0 additions & 24 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import (
"github.com/massalabs/DeWeb/int/utils"
"github.com/massalabs/DeWeb/int/zipper"
pkgConfig "github.com/massalabs/DeWeb/pkg/config"
"github.com/massalabs/DeWeb/pkg/webmanager"
"github.com/massalabs/DeWeb/pkg/website"
msConfig "github.com/massalabs/station/int/config"
"github.com/massalabs/station/pkg/cache"
"github.com/massalabs/station/pkg/logger"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -254,7 +252,6 @@ func viewWebsite(scAddress string, networkInfos *msConfig.NetworkInfos) error {
logger.Infof("Website owner: %s", owner)

// For debugging cache purposes:

// zipFile, err := webmanager.RequestWebsite(scAddress, networkInfos)
zipFile, err := website.Fetch(networkInfos, scAddress)
if err != nil {
Expand Down Expand Up @@ -294,27 +291,6 @@ func deleteWebsite(siteAddress string, config *yamlConfig.Config) error {

logger.Infof("Website %s deleted with operation ID: %s", siteAddress, *operationID)

err = deleteFromCache(siteAddress)
if err != nil {
return fmt.Errorf("failed to delete %s from cache: %v", siteAddress, err)
}

logger.Infof("Website %s deleted from cache", siteAddress)

return nil
}

func deleteFromCache(scAddress string) error {
cache := new(cache.Cache)
fileName := fmt.Sprintf("website_%s.zip", scAddress)

if cache.IsPresent(fileName) {
err := os.Remove(webmanager.CacheDir + fileName)
if err != nil {
return fmt.Errorf("failed to delete from cache: %v", err)
}
}

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/config/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const (

MainnetChainID = 77658377
BuildnetChainID = 77658366

DefaultNodeURL = "https://buildnet.massa.net/api/v2"
)

func NewNetworkConfig(NodeURL string) msConfig.NetworkInfos {
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ type WalletConfig struct {
NodeUrl string
}

const DefaultNodeURL = "https://buildnet.massa.net/api/v2"

func NewWalletConfig(walletNickname string, nodeURL string) WalletConfig {
return WalletConfig{
WalletNickname: walletNickname,
Expand Down
4 changes: 2 additions & 2 deletions pkg/webmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/massalabs/station/pkg/logger"
)

const CacheDir = "./websitesCache/"
const cacheDir = "./websitesCache/"

// getWebsiteResource fetches a resource from a website and returns its content.
func GetWebsiteResource(network *msConfig.NetworkInfos, websiteAddress, resourceName string) ([]byte, bool, error) {
Expand Down Expand Up @@ -100,7 +100,7 @@ func fetchAndCache(networkInfo *msConfig.NetworkInfos, scAddress string, cache *

// Compares the last updated timestamp to the file's last modified timestamp.
func isFileOutdated(fileName string, lastUpdated time.Time) (bool, error) {
fi, err := os.Stat(CacheDir + fileName)
fi, err := os.Stat(cacheDir + fileName)
if err != nil {
return false, fmt.Errorf("failed to get file info: %w", err)
}
Expand Down

0 comments on commit 83ba542

Please sign in to comment.